Name: lc1-external-challenge-service
Owner: Topcoder
Description: This code will provide an getActiveChallenges service form LC to be used by TC
Created: 2014-10-20 15:48:06.0
Updated: 2015-02-11 21:26:16.0
Pushed: 2015-02-11 21:26:16.0
Homepage: null
Size: 3373
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This deliverable, hereafter named serenity-list, is a simple nodeJS application that returns listing of all active challenges in Serenity and transform the data a little bit so it can be used by the existing Topcoder site.
Serenity-list is written with NodeJS. This application is part of Project SERENITY, a refresh of the topcoder challenge lifecycle. The details of the challenge can be found here
To use this application, follow these steps:
cd YOUR_UNZIPPED_PATH/serenity-list
.npm install
to install any dependencies required by this application.serenity-list/config.js
as needed, maybe changing the port this app will listen to.node app
to start the application. If it's succesful, the terminal will display Listening on port x
where x is the port number.To test this application, send GET request to http://localhost:12345/getActiveChallenges
. It can be as simple as accessing with your favorite browser. You can also use Postman plugin to make it pretty and easy to look at.
Since this application is advised to use sequelize just like in serenity-core. Some files, all in Challenge Package, are initially copied over from serenity-core. Those files are:
controllers/challenges.js
. All functions except .all
are removed. .all
is renamed into .allActiveChallenges
to better reflect its new function. The query result is not returned directly, it is converted first into the format that can be used by the existing Topcoder site.lib/routeHelper.js
. Unchanged.models/challenge-registrant.js
. Add belongsTo
association with Challenge model.models/challenges.js
. Add hasMany
association with ChallengeRegistrant model.models/index.js
. Unchanged.datasource.js
. Unchanged.These are the other untracked files and a short of explanation of what are they used for:
format/challenge-tc-format.js
. This module contains the logic to convert Serenity Challenge data into the format used by the existing Topcoder site. Please see here to check the mapping table.app.js
. This module is the entry-point for serenity-list. It initializes datasource in datasource.js
, defines the route, and initiates listening to the port for incoming request.config.js
. This is the configuration file. The database configuration is copied from serenity-core config/env/development.js
. There is also port number if you want to change it.package.json
. What's important here is the list of dependencies. The version number is made similiar with what exists in serenity-core.README.md
.These are the requirements listed by the challenge:
Create a node app with single service with an endpoint called /getActiveChallenges that only get challenges whos status is NOT draft or complete.
The route can be found in app.js
. The query condition can be found in controllers/challenges.js
.You should may use serenity-core1 repo which has the config file (development) that will connect you to our sample databases.
The database configuration can be found in config.js
.You should use sequelize like in this repo but not all the mean stuff, Should be very small app no overhead.
For sequelize, controllers/challenges.js
, models
, and datasource.js
are copied from serenity-core. The model and the controller are changed a bit to fulfill the requirements and some unnecessary parts unused in serenity-list are removed.tc stores dates in EST and lc stores in UTC so we must subtract 4 hours from all our timesstamps.
Date conversion can be found in format/challenges-tc-format.js
.Create a urlPrefix variable in the config file with the value equal to 'http://serenity-core1.herokuapp.com/#!/challenges/'
The variable can be found in config.js
.Any property with NOTES = DONT RETURN do no return (see mapping table)
See format/challenges-tc-format.js
to check if it's correct.For 'numRegistrants' you will need to resolve the count from the Registrants table (see mapping table). You can do this by do a db call (via sequlize) and passing in the challenge id, or but setting up the relationship via the model (see how files and attachments are done, this is perfered if possible)
See format/challenges-tc-format.js
to check if it's correct. Serenity-list uses sets up the relationship via the model
method.Look at issue #46 ( https://github.com/topcoderinc/serenity-core/issues/46 ) for the mapping table.
See format/challenges-tc-format.js
and the link to check if it's correct.