Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

sobiyang/VaultdragonCodingTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Motivation

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.

Usage

  • 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

Notes

  • 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 reference

API key: 6cd745f5c27d8e819b4f63e4e2d5e9b9f606ce7fad52cd93cf7fabbe7e5d2d9f

Retrieve value

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&timestamp=1500615492033

Example response:

{
    "value": "test4"
}

Upload key-value pair

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"
}

Built With

  • restify - Node.js REST framework

  • sqlite3 - Node.js implementation of SQLite database

  • Promises - A a simple implementation of Promises

Personal notes

  • 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

Author

Brian Yang

About

Solution for Vaultdragon Coding Test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages