An open API service indexing awesome lists of open source software.

https://github.com/nishant-sethi/confusion-nodejs

This is the backend server for a restaurant named Con Fusion, a practice project to learn javascript backend development.
https://github.com/nishant-sethi/confusion-nodejs

backend-server coursera-assignment expressjs fullstack-javascript mongodb nodejs

Last synced: 27 days ago
JSON representation

This is the backend server for a restaurant named Con Fusion, a practice project to learn javascript backend development.

Awesome Lists containing this project

README

          

# Con Fusion Server

This is the backend server for a restaurant named _Con Fusion_,
a practice project to learn javascript backend development.

It is written using
[Node.js](https://nodejs.org) as runtime,
[Express.js](https://expressjs.com) as application framework.
The project structure is generated by
[Express Generator](https://expressjs.com/en/starter/generator.html)
It uses [MongoDB](https://mongodb.com) as the persistent data store,
and [Mongoose](https://mongoosejs.com) ODM (object-document mapper).

## Requirements

- [Node.js](https://nodejs.org) (and [npm](https://npmjs.com))
- [MongoDB](https://mongodb.com)

## How to see it in action

First of all, start a MongoDB server at port 54321. For example:

mongod --dbpath=/tmp/data --port=54321

Then just clone and run:

1. Clone the repo, and `cd` into it

git clone https://github.com/nishant-sethi/coursera-nodejs-confusion
cd coursera-nodejs-confusion

2. Initall npm dependencies

npm install

3. Start the server

npm start

4. Send requests to [http://localhost:3000](http://localhost:3000)

### Authentication

Right now, it uses simple JWT-based authenticationUse the following API for authentication:

Operation | Method | URL | Body
--- | --- | --- | ---
Signup | POST | /users/signup | `{ "username": "abc", "password": "xyz" }`
Login | POST | /users/login | `{ "username": "abc", "password": "xyz" }`
Logout (_not used_) | GET | /users/logout |

When you login, you'll receive a _`token`_ in the response body.
Put that token in the request header as `Authentication: Bearer ` to
access restricted endpoints. The default expiration time of the tokens in 1 hour.
You'll have to relogin and obtain new token when the current token expires.

## API Endpoints

Endpoint | Supported methods
--- | ---
`/dishes` | GET, POST, DELETE
`/dishes/` | GET, PUT, DELETE
`/dishes//comments` | GET, POST, DELETE
`/dishes//comments/` | GET, PUT, DELETE
`/promotions` | GET, POST, DELETE
`/promotions/` | GET, PUT, DELETE
`/leader` | GET, POST, DELETE
`/leader/` | GET, PUT, DELETE
`/users` | GET

### Method documentation

Method | Description | Access Control
--- | --- | ---
GET | Retrieve record(s) | Usually public
POST | Insert new record in the collection | Requires authentication
PUT | Modify a record | Requires authentication
DELETE | Delete record(s) | Requires authentication

## Reference

- [Server-side Development with NodeJS, Express and MongoDB, Coursera](https://www.coursera.org/learn/server-side-nodejs)