JJuOn

Add routing challenge api

...@@ -25,7 +25,6 @@ exports.getChallenge = async (ctx) => { ...@@ -25,7 +25,6 @@ exports.getChallenge = async (ctx) => {
25 endDate: Date Object, 25 endDate: Date Object,
26 durationPerSession: "2w", // '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session. 26 durationPerSession: "2w", // '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session.
27 goalPerSession: 3, 27 goalPerSession: 3,
28 - groups: [{'name1', 'name2'}]
29 } 28 }
30 */ 29 */
31 exports.addChallenge = async (ctx) => { 30 exports.addChallenge = async (ctx) => {
...@@ -35,8 +34,7 @@ exports.addChallenge = async (ctx) => { ...@@ -35,8 +34,7 @@ exports.addChallenge = async (ctx) => {
35 startDate: Joi.date(), 34 startDate: Joi.date(),
36 endDate: Joi.date(), 35 endDate: Joi.date(),
37 durationPerSession: Joi.string(), 36 durationPerSession: Joi.string(),
38 - goalPerSession: Joi.number(), 37 + goalPerSession: Joi.number()
39 - groups: Joi.array().items(Joi.string()),
40 }) 38 })
41 .unknown(); 39 .unknown();
42 const result = Joi.validate(ctx.request.body, schema); 40 const result = Joi.validate(ctx.request.body, schema);
......
1 +const Router = require('koa-router');
2 +const challenge = new Router();
3 +const challengeCtrl = require('./challege.ctrl');
4 +
5 +challenge.post("/getchallenge",challengeCtrl.getChallenge);
6 +challenge.post("/addchallenge",challengeCtrl.addChallenge);
7 +
8 +module.exports = challenge;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,11 +6,13 @@ const friend = require("./friend"); ...@@ -6,11 +6,13 @@ const friend = require("./friend");
6 const notify = require("./notify"); 6 const notify = require("./notify");
7 const user = require("./user"); 7 const user = require("./user");
8 const profile = require("./profile"); 8 const profile = require("./profile");
9 +const challenge = require("./challenge");
9 10
10 api.use("/auth", auth.routes()); 11 api.use("/auth", auth.routes());
11 api.use("/friend", friend.routes()); 12 api.use("/friend", friend.routes());
12 api.use("/notify", notify.routes()); 13 api.use("/notify", notify.routes());
13 api.use("/user", user.routes()); 14 api.use("/user", user.routes());
14 api.use("/profile", profile.routes()); 15 api.use("/profile", profile.routes());
16 +api.use("/challenge",challenge.routes());
15 17
16 module.exports = api; 18 module.exports = api;
......