Skip to content
Jeff Douglas edited this page Apr 1, 2015 · 12 revisions

We will be building the API using the github issues. I'll be adding all of the work to be done as issue. Simply fork the application, assign yourself to an issue you would like to work on, implement the code (and mocha test if required) and send a pull request. Please do not assign yourself to more that one issue at a time.

Make sure you update frequently (after submitting a pull request) from the master repo to ensure you have the latest code.

The Swagger API definition file is located here. Simply paste the contents into the Swagger Editor to get started.

Requirements

  1. Node
  2. MongoDB

Running Locally

git clone [email protected]:topcoderinc/TopBlogger.git
cd TopBlogger/api
npm start

Models

Feel free to make any necessary model changes but ensure they don't negatively impact any other code.

Authentication

The first thing you need to do is register a new user. To do so navigate to http://localhost:3000/register and fill all fields. After the registration is complete you need to login. Go to /login and provide your credentials. If success then you will see your JWT which can be used to access /api endpoints. Make a request to an endpoint that requires authentications you must include the JWT to in the header. You can test by doing a GET to /api/secret including the 'Authorization: JWT ' header which should display a success message.

To add authorization for a route, simply add AuthChecker to the route like below:

/* API endpoint which require auth. */
router.get('/secret', AuthChecker, function (req, res) {
    res.json({
        version: 1.0
    });
});

During development you may want to disable the authentication requirement but remember to add it back and test for it.

Testing

npm test

Development

We will be using bluebird whenever promises are required and mocha for testing. You will need to submit mocha tests to cover your with each submission. Each API call should handle errors and return proper HTTP response codes.

Clone this wiki locally