Skip to content

Commit 3793423

Browse files
committed
Added env file and updated read me.
1 parent 7697e61 commit 3793423

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

.env

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DB_URL=mongodb://localhost:27017/tododb
2+
PORT=4040
3+
BASE_URL=http://localhost:4040
4+
APP_SECRET=qwertyuiop
5+
JWT_EXPIRES_IN=1d

.gitignore

+2-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ typings/
5454
# Yarn Integrity file
5555
.yarn-integrity
5656

57-
# dotenv environment variables file
58-
.env
59-
6057
## Directory-based project format:
6158
.idea/
6259
.tmp/
60+
61+
package-lock.json

README.md

+21-9
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ Simple node js api project with jwt authentication with mongodb.
55

66
This is assumed that npm, node and mongodb are installed on the machine.
77

8-
* node js >= 6.9.x
9-
* npm >= 3.x.x
8+
* node js >= 8.x
9+
* npm >= 5.x
1010
* mongodb >= 3.2.x
11-
11+
1212
For installing node and npm please refer [here](https://nodejs.org/en/download/package-manager/).
1313
For installing mongodb [here](https://docs.mongodb.com/manual/installation/).
1414

15+
> Note: I recommended to use npm@5, Because it provides `npm audit` facility to check vulnerability in your dependencies.
16+
17+
1518
## Installation and Run
1619

1720
1. Clone the repository and move to cloned directory and hit:
@@ -30,12 +33,21 @@ For installing mongodb [here](https://docs.mongodb.com/manual/installation/).
3033
npm start
3134
```
3235
33-
This will start the project.
36+
This will start the project on the port number as you specify in `.env` file. Default is `4040`, so you API is now on [https://localhost:4040](http://localhost:4040) url.
37+
38+
39+
## Configuration
3440
35-
## Disable JWT
41+
1. Configuration application using `.env` file by setting environment variable.
42+
43+
2. Disable JWT authentication
44+
45+
By commenting following line you can disabled JWT verification in index.js.
46+
47+
```
48+
// app.use(expressJwt({secret: process.env.APP_SECRET}).unless(filter));
49+
```
3650
37-
By commenting following line you can disabled JWT verification in index.js.
51+
## License
3852
39-
```
40-
// app.use(expressJwt({secret: process.env.APP_SECRET}).unless(filter));
41-
```
53+
MIT

0 commit comments

Comments
 (0)