- Built a rest Api in Node.js by leveraging below-mentioned Node.js modules.
- Used JSON web tokens for token-based user authentication
- Used Passport module together with passport-local and passport-local-mongoose for setting up local authentication within server.
- Used Mongoose population to cross-reference users within a comment.
- Configured a secure server in Node using the core HTTPS module.
- Generated the private key and public certificate and configure the HTTPS server.
- Used an OAuth providers for authenticating users within your server.
- Set up your server using Passport OAuth modules to enable user authentication using OAuth providers.
- Checks if a verified ordinary user also has admin privileges.
- Allow an ordinary user to only perform GET operatioins
- Only allows Admin to perform POST, PUT and DELETE operations
- Only allows Admin to be able to GET all the registered users' information from the database
-
Clone or download the repo. into any fresh temporary folder.
-
Cd into that root folder you just cloned locally.
-
Open terminal in the current folder and to install all dependencies type
npm install
- Now typing
npm start
- will start a server !
- MLab's MongoDB hosting platform is the fastest growing cloud Database-as-a-Service in the world. Get started with a free database and expert support.
- NPM is the default package manager for the JavaScript runtime environment Node.js.
- For dependencies refer Package.json.
- Postman extension can be used for testing !
- Supercharge your API workflow with Postman! Build, test, and document your APIs faster.
- You can now fire up postman and then perform several operations on the REST API.
- You can use the data for all the dishes,promotions and leadership provided in the db.json file .
-
Create your branch:
git checkout -b my-new-feature
-
Commit your changes:
git commit -m 'Add some feature'
-
Push to the branch:
git push origin my-new-feature
-
Send a Pull Request
-
Enjoy!
- POST Request to URL localhost:3443/users/register (For user registration !)
- POST Request to URL localhost:3443/users/login (For user login !)
- GET Request to URL localhost:3443/dishes/ (User Authenticated !)