Skip to content
Jeff Douglas edited this page Apr 6, 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 with mocha tests and send a pull request. Send a pull request for each issue. Do not assign yourself to a new issue until you have submitted a pull request. I'll be monitoring to make sure people don't have multiple issues.

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

Each issue corresponds to a route defined in the Swagger API definition. To view the API documentation, simply paste this file into the Swagger Editor.

Requirements

  1. Node
  2. MongoDB

Running Locally

git clone git@github.com: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 [token]' 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

Make sure you run /tmp/load to load all of the mock objects that is needed for 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.

Questions??

Post them on the individual github issues or if they are general in nature the topcoder board.

Payments

When all issues are closed for the API build we will total up the amount for each member's issues implemented and pay through topcoder as usual.