ApiREST with NodeJS, Express, MongoDB and Postman. Model View Controller (MVC) design pattern and validation with JSON Web Token (JWT).
Project completed.
↓ Installation of CORS (Cross-Origin Resource Sharing), Dotenv: Library to load variables and Multer: Middleware to handle file uploads.
npm i cors dotenv multer
↓ Installation of the express validator, which filters the data before it reaches the controller.
npm i express-validator --S
↓ Installation of plugin to delete by soft-delete.
npm i mongoose-delete --save
↓ Installation of the json web token (JWT) for session control.
npm i jsonwebtoken --save
↓ Installation of bcrypt and bcryptjs to encrypt data.
npm i bcryptjs bcrypt --save
↓ Start app.js using node.
node app.js
↓ Installation of a package to automatically restart the connection in case of code changes.
npm i nodemon -g
↓ Add inside the “scripts” section in package.json.
"start": "node ./app.js",
"dev": "nodemon ./app.js",
↓ Start the project with nodemon.
npm run start:dev
IMPORTANT: Keep the terminal running for the correct execution of the app.