This is my attempt to Vaultdragon Coding Test.
It uses restify to handle server and API logics, uses SQLite for database, and Promises to simplify the async flow.
-
The API is at https://brian-yang-coding-test.herokuapp.com
-
A valid API key is required, it should be in api_key field in HTTP URL query, and is given below
-
The timestamp should be in milliseconds
-
For POST method, HTTP headsers should have
Content-Type: application/json
-
API request timeout: 30 seconds
-
SQLite lock table timeout: 5 seconds
-
Non-standard characters not handled
-
Potential database issues not considered
-
Heroku free account's instance goes to sleep when it receives no traffic in a 30 minute period, which means the first API call might be slow
API key: 6cd745f5c27d8e819b4f63e4e2d5e9b9f606ce7fad52cd93cf7fabbe7e5d2d9f
GET /object/{key}
Fields:
Property Name | Data Type | Remarks |
---|---|---|
key | string | |
timestamp | long | optional, in milliseconds |
Example request:
https://brian-yang-coding-test.herokuapp.com/object/test?api_key=6cd745f5c27d8e819b4f63e4e2d5e9b9f606ce7fad52cd93cf7fabbe7e5d2d9f×tamp=1500615492033
Example response:
{
"value": "test4"
}
POST /object/
Example request and body:
https://brian-yang-coding-test.herokuapp.com/object?api_key=6cd745f5c27d8e819b4f63e4e2d5e9b9f606ce7fad52cd93cf7fabbe7e5d2d9f
{
"test": "test4"
}
Example response:
{
"key": "test",
"value": "test4",
"timestamp": "2017-07-21T05:36:13.246Z"
}
-
restify - Node.js REST framework
-
sqlite3 - Node.js implementation of SQLite database
-
Promises - A a simple implementation of Promises
-
It took me 3 hours for coding and testing, 2 hours for Heroku and GitHub setup and running, and 1 hour for adding documentation and comments
-
I have no prior knowledge of restify or Promises, and before this I have no experience in developing a complete Node.js app, or deploying apps on Heroku
-
It's fun to learn all these, and ES6 version of JavaScript looks nice, maybe I'll try it later