Code Monkey home page Code Monkey logo

key-value-swagger-express-mongodb's Introduction

Key-Value pair using swagger-express-middleware with MongoDB

This is an API application that stores a key-value pair and retrieves the latest value stored in the system

Installation

Pre-requisites (install with -g option)

Application setup

$ git clone https://github.com/dennisjade/key-value.git
$ cd key-value
$ npm install
$ npm start

Running tests

$ npm test

Viewing test coverage

  • In the root directory, run the command below
  • To view the HTML version report, go to coverage/lcov-report/index.html
$ ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha  test/**/*

Creating the API doc

$ apidoc -i api -o doc/

Swagger UI (To test the APIs using browser)

$ swagger project edit

Available APIs

Method Route Params Description
GET /object/key NONE Retrieves latest value stored based on the key
GET /object/key timestamp Retrieves latest value stored based on key and within timestamp
POST /object key;value Add key-value pair in DB. Pass inside the body

Sample API calls

$ curl -X 'GET' http://localhost:10010/object/1

$ curl -X 'GET' http://localhost:10010/object/1?timestamp=1505231250937

$ curl -H "Content-Type: application/json" -X POST -d '{"animal":"cat"}' http://localhost:10010/object

key-value-swagger-express-mongodb's People

Contributors

dennisjade avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.