File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,32 +22,37 @@ body:
2222```
2323{
2424 key: 'your key',
25- value: 'your value',
26- timestamp: default to current time in epoch seconds format
25+ value: 'your value'
2726}
2827```
2928
3029#### GET an item by [ key]
3130` https://nodejs-api-myce.herokuapp.com/[key] `
3231
3332#### GET an item by [ key] and timestamp query string
34- ` https://nodejs-api-myce.herokuapp.com/[key]?timestamp=[epoch time in second ] `
33+ ` https://nodejs-api-myce.herokuapp.com/[key]?timestamp=[epoch_time_in_second ] `
3534
3635## Developers Guide
3736` npm version: 5.4.2 `
3837
3938` node version: 8.5.0 `
4039
40+ ` mongodb: mlab ` at https://mlab.com
41+
4142#### Getting Started
42- 1 . Create mlab database at https://mlab.com/
43- 2 . Create a ` user ` and ` password ` for the database
44- 3 . Create a ` .env ` file in root project folder
45- 4 . Add the following credential into the ` .env ` file
43+ 1 . Create mongodb database
44+ 2 . Create a ` .env ` file in root project folder
45+ 3 . Add the following credential to the ` .env ` file
46+
47+ DB_URL=[ YOUR_DB_URL]
48+
49+ DB_TEST_URL=[ YOUR_TEST_DB_URL]
4650
47- DBUSER= [ YOUR_DB_USERNAME ]
51+ 4 . Run ` npm install `
4852
49- DBPASSWORD= [ YOUR_DB_PASSWORD ]
53+ 5 . Run ` npm start `
5054
51- 5 . Run ` npm install `
55+ #### Test
56+ Test framework: ` mocha, chai, chai-http `
5257
53- 6 . Run ` npm start `
58+ 1 . Run ` npm test `
Original file line number Diff line number Diff line change 11var mongoose = require ( 'mongoose' ) ;
22let DBUSER = process . env . DBUSER
33let DBPASSWORD = process . env . DBPASSWORD
4- mongoose . connect ( `mongodb://${ DBUSER } :${ DBPASSWORD } @ds151014.mlab.com:51014/vdragon` )
4+
5+ if ( process . env . NODE_ENV === 'test' ) {
6+ mongoose . connect ( process . env . DB_TEST_URL )
7+ } else {
8+ mongoose . connect ( process . env . DB_URL )
9+ }
You can’t perform that action at this time.
0 commit comments