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.
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.
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
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
You can
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
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 needsudo
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> .
- 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
Please read CONTRIBUTING.md for details on our code.
- Felice Pagano - felicepagano