JJuOn

Add routing challenge api

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