Simple node js api project with jwt authentication with mongodb.
This is assumed that npm, node and mongodb are installed on the machine.
- node js >= 10.x.x
- npm >= 6.x.x
- mongodb >= 4.2.x
For installing node and npm please refer here. For installing mongodb here.
Note: I recommended to use npm@5, Because it provides
npm auditfacility to check vulnerability in your dependencies.
-
Clone the repository and move to cloned directory and hit:
npm installThis will install all the dependencies for the project.
-
To start the project hit:
node index.route.jsor
npm startThis will start the project on the port number as you specify in
.envfile. Default is4040, so you API is now on https://localhost:4040 url.
-
Configuration application using
.envfile by setting environment variable. -
Disable JWT authentication
By commenting following line you can disabled JWT verification in index.route.js.
// app.use(expressJwt({secret: process.env.APP_SECRET}).unless(filter));
MIT