Coder Social home page Coder Social logo

buildo-conf-api's Introduction

Configuration API

HTTP APIs for managing the configuration values of a system. These API are exposed through nodejs and express web server and the configuration object are stored and retrieved from a mongodb instance. The entire infrastructure is provided by a docker-compose file, so no deploy phase is necessary.

Resources are provided in json format. APIs produces and consumes the following model:

{
	"_id": "foo",
	"name": "Configuration for Foo",
	"value": "This is the value for configuration Foo"
}

express will expose the following api:

'GET /configurations' will return all the configurations. 'POST /configurations' with a JSON payload will create a new entry. 'PUT /configurations/:id' will update the object with the given id. 'GET /configurations/:id' will return the object with the given id. 'DELETE' will delete the object with the given id.

here you can find the API calls for postman. here you can find a live server with the latest version of the API.

generator-api โ† Click here for details.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

You can run the entire application stack locally with docker without the need to install all the dependencies in your dev machine.

Docker ๐Ÿณ & docker-compose.

As developer, you will need to install the following tools:

nodejs/npm and the following packages globally:

โ”œโ”€โ”€ yo
โ”œโ”€โ”€ generator-api
โ”œโ”€โ”€ jsdoc
โ”œโ”€โ”€ mocha
โ””โ”€โ”€ yarn

e.g.

yarn install -g yarn

yo (yeoman) is a scaffolding tool.

generator-api a yeoman generator for creating RESTful NodeJS APIs, using ES6, Mongoose and Express.

jsdoc an API documentation generator for JavaScript.

yarn dependecies management.

mocha test framework

Running the tests

Under the ./node/test folder you can find the package.json file. This is a copy of the ./node/src/package.json. I didn't find a nice way to share the two files, so I'm fine with a little effort to maintains both.

You need the following steps to run tests:

yarn install -g yarn
yarn install -g mocha

npm install
npm test

This will execute all the js files under the ./node/test/ directory

Running the generated project

You can

Development

If you would like to run the application out of the container make sure you have node version >= 6 because this project uses native supported ES6 features.

Inside the ./node/src directory type the following commands:

yarn install
npm dev

https://github.com/remy/nodemon

Production

You only need Docker and docker-compose installed, forget about having node, mongodb or npm.

  • Run: docker-compose up to run the app. You might need sudo for this one

NOTE: The Dockerfile uses node:latest as its starting point, if you wish to use another version of Node check out the available ones here.

The Docker image is available on docker-hub and his build is triggered by github commits; you can find the latest available image on docker-hub

You can also build your image using the following command under the ./node/ folder:

sudo docker build -t <image-name> .

Built With

  • npm - Dependency Management
  • express - The web framework used
  • bluebird - Third party promise library
  • body-parser - body parsing middleware.
  • express-mongoose-status - handle mongoose responses and convert them to correct HTTP status in a REST API using Express
  • helmet - Helmet helps you secure your Express apps by setting various HTTP headers.
  • http-status-codes - Constants enumerating the HTTP status codes.
  • mongoose - elegant mongodb object modeling for node.js
  • morgan - HTTP request logger middleware for node.js

Contributing

Please read CONTRIBUTING.md for details on our code.

Authors

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.