Simple nodejs api that can perform the following tasks:
-
Accept a key(string) and value(some json blob/string) {"key" : "value"} and store them. If an existing key is sent, the value should be updated
-
Accept a key and return the corresponding latest value
-
When given a key AND a timestamp (as query string), return whatever the value of the key at the time was.
-
List all items.
End Point: https://nodejs-api-myce.herokuapp.com/
https://nodejs-api-myce.herokuapp.com/items
https://nodejs-api-myce.herokuapp.com/items
body:
{
key: 'your key',
value: 'your value'
}
https://nodejs-api-myce.herokuapp.com/[key]
https://nodejs-api-myce.herokuapp.com/[key]?timestamp=[epoch_time_in_second]
npm version: 5.4.2
node version: 8.5.0
mongodb: mlab
at https://mlab.com
- Create mongodb database
- Create a
.env
file in root project folder - Add the following credential to the
.env
file
DB_URL=[YOUR_DB_URL]
DB_TEST_URL=[YOUR_TEST_DB_URL]
-
Run
npm install
-
Run
npm start
Test framework: mocha, chai, chai-http
- Run
npm test