From a22820c278e84193ed7bd6c6e5364bf108202331 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Wed, 5 Aug 2015 00:51:39 +0300 Subject: [PATCH] + /schedules route; other update --- routes/schedule.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/routes/schedule.js b/routes/schedule.js index 82febb79..dfecfab1 100644 --- a/routes/schedule.js +++ b/routes/schedule.js @@ -44,4 +44,20 @@ module.exports = function (app) { } )) ); + + app.use( + route.get("/schedules", router.accepts( + { + "text/html": router.index(), + "text/plain": router.index(), + + "application/json": function *() { + this.type = "application/json"; + var data = yield db.c("schedules").find({}, {period:1 , semester: 1}).toArray(); + if(!data) this.status = 404; + else this.body = data; + } + } + )) + ); }; \ No newline at end of file