Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Contact Service

Build Status Carbon Version

This example illustrates the use of to implement a public API for managing personal contacts. This API also handles user management, and allows for new users to register via the API, and then use the API to manage their contacts separate from other users' contacts.

Installing the service

We encourage you to clone the git repository so you can play around with the code.

$ git clone
$ cd contacts-service-advanced
$ npm install

Setting up your environment

This example expects a running MongoDB database. The code will honor a DB_URI environment variable. The default URI is mongodb://localhost:27017/contacts.

To set the environment variable to point the app at a database different from the default (on Mac):

$ export DB_URI=mongodb://localhost:27017/mydb

Running the service

To run the service:

$ node lib/ContactService

For cmdline help:

$ node lib/ContactService -h

Accessing the service

You can interact with the service via HTTP. Here is an example using curl to create a new user:

$ curl localhost:9900/users -H "Content-Type: application/json" -d '{"email":"", "password":"foobar"}'

Running the unit tests

This example comes with a simple unit test written in's test framework called TestTube. It is located in the test directory.

$ node test/ContactServiceTest


$ npm test

Generating API documentation (aglio flavor)

To generate documentation using aglio, install it as a devDependency:

$ npm install -D --no-optional aglio

Using --no-optional speeds up aglio's install time significantly. Then generate the docs using this command:

$ node lib/ContactService gen-static-docs --flavor aglio --out docs/index.html


An API for managing contacts




No releases published


No packages published