Key Information

Register
Submit
The challenge is finished.

Challenge Overview

We are preparing for a Member Settings Service, and the first feature in the service will be saved searches.

Project Location

https://github.com/topcoderinc/tc-user-settings

Description

You’ll be extending this boilerplate nodejs api project to include its first endpoint:  /saved-searches

Take a look at server.js for the 5 functions you will be delivering, and the intended purpose of each. All endpoints continuing from / (including the one implemented here /saved-searches) are to be unique and relevant to the user requesting the resource.

You can assume that the authentication middleware will populate req.user.id with a unique id for that user and will return an error if the credentials presented to this microservice are invalid.

The settings for a user will be created as soon as a new req.user.id is presented in a post to create a saved-setting

The get, put, and delete functions should behave identically if there is no settings or no saved-settings.

The get all should always return a JSON array, empty if none.

The get, put, and delete (calls with id) should return a 404 if anything doesn’t exist for that user (settings, saved-searches, or saved-search with that id)

The post call should create any necessary objects necessary to create the saved-search (user record, settings for that user).

The persistent storage for the user settings object and the saved settings for the saved settings object should be provided by a simple mongodb instance running on localhost. The standard mongodb driver should be used:

http://docs.mongodb.org/ecosystem/drivers/node-js/

You may use mongoose to define/enforce the schema, but it is not required.

In general if you have any question about the implementation of REST to use, follow this standard: https://github.com/WhiteHouse/api-standards/, or reach out on the forums.

JSON Responses

The JSON for a saved-search should look like this:

{

    'type': 'develop' //one of develop, design, data

    'filter': '?technologies=ASP.NET&platforms=Cisco'

}

The included body-parser package should provide that object as req.body, so those properties will be available as req.body.type and req.body.filter.

POST Validation/ Error Messages:

Use 400 status code for all error including the appropriate json response.

Both properties are required, or return:

{

    "status" : 400,

    "developerMessage" : "A required property was not provided: " + type or filter,

    "errorCode": 1

}

 

The filter parameter must be less than 2000 characters, or return:

{

    "status" : 400,

    "developerMessage" : "The filter property must contain less than 2000 characters",

    "errorCode": 2

}

 

When the object is returned to the user, it should contain its id:

{

    'id': 'unique_database_id'

    'type': 'develop' //one of develop, design, data

    'filter': '?technologies=ASP.NET&platforms=Cisco'

}


 

Submission Requirements

 

Extend the readme with any additional instructions required due to requirements you introduce. In cases like the installation of mongo, a simple reference to the docs is sufficient, but if there are any non default settings in the installation, be sure to provide those.

 

Include any addition npm packages in the package.json file (I use npm install --save).

 

All 5 endpoints should be fully functional and keyed by req.user.id (a different set of saved searches/settings should be stored/returned if a different req.user.id is provided).

Code will be judged negatively based on repetition, avoid duplication in your code.

Javascript Standards

All the code must pass jslint, You may use 'nomem: true'.

Use Cases

  1. As an API consumer, when I make a POST call to /saved-searches, the JSON I provide should be assigned a unique ID and stored.

  1. As an API consumer, when I make a GET call to /saved-searches, an array containing all the JSON objects I have POSTed should be returned, with each saved search including its unique ID.

  2. As an API consumer, when I make a GET call to /saved-searches/id, where id is a valid unique ID, the saved search should be returned including its unique ID.

  3. As an API consumer, when I make a PUT call to /saved-searches/id, where id is a valid, existing unique ID, the JSON I provide should replace the existing object (except the unique ID itself, which must remain constant).

  4. As an API consumer, when I make a DELETE call to /saved-searches/id, where SSID is a valid unique ID, any data associated with that unique ID should be removed, and all subsequent GET and PUT calls should not include the data.



Final Submission Guidelines

  • updated source code for implementing the required functionaliy
  • winner will be responsible for merging.

ELIGIBLE EVENTS:

2015 topcoder Open

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30046332