Skip to content

Commit

Permalink
Added getevents service
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargarcia-tines committed Aug 23, 2017
1 parent b6b45ec commit 161461e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
20 changes: 20 additions & 0 deletions app/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
exports.getevents = function() {

return ([
{ series: "IMSA", year: "2017", event: "DAYTONA" },
{ series: "WEC", year: "2016", event: "SILVERSTONE" },
{ series: "WEC", year: "2016", event: "SPA" },
{ series: "WEC", year: "2016", event: "LE_MANS" },
{ series: "WEC", year: "2016", event: "NURBURGRING" },
{ series: "WEC", year: "2016", event: "MEXICO" },
{ series: "WEC", year: "2016", event: "AUSTIN" },
{ series: "WEC", year: "2016", event: "FUJI" },
{ series: "WEC", year: "2016", event: "SHANGHAI" },
{ series: "WEC", year: "2016", event: "BAHRAIN" },
{ series: "WEC", year: "2017", event: "SILVERSTONE" },
{ series: "WEC", year: "2017", event: "SPA" },
{ series: "WEC", year: "2017", event: "LE_MANS" },
{ series: "WEC", year: "2017", event: "NURBURGRING" },
]);

}
16 changes: 15 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ var port = process.env.PORT || 8080; // set our port
var router = express.Router(); // get an instance of the express Router

// Get race data API service
// Get race data API service
router.route('/getevents')

.get(function(req, res,next) {

var evnt = require("./app/events.js");

var eventData=evnt.getevents();

res.contentType('application/json');
res.send(JSON.stringify(eventData));

});

router.route('/:series/:year/:race')

.get(function(req, res,next) {
Expand All @@ -19,7 +33,7 @@ router.route('/:series/:year/:race')
var sec = require("./app/seconds.js");

//parsing the CSV file

var file = "resources/" + req.params.series + "/" + req.params.year
+ "/" + req.params.race + ".CSV";

Expand Down
12 changes: 12 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ describe('Stats api', () => {

});

describe('/GET getevents', () => {

it('Returns 200', (done) => {
chai.request(server)
.get('/api/getevents')
.end((err, res) => {
res.should.have.status(200);
done();
});
});
});

describe("Seconds Function", () => {

it('Manages times with hours', (done) => {
Expand Down

0 comments on commit 161461e

Please sign in to comment.