import * as express from "express"; import * as bodyparser from "body-parser"; import { authRoute } from "../security/token"; const userRouter = express.Router(); userRouter.use(bodyparser.json()); userRouter.use(authRoute); // Return the user object if the user is still authenticated userRouter.get("/get", async (req, res) => { console.log("STUB: /user/get"); // TODO: Stub res.send({ error: "0", data: { test: 0, }, }); }); // Removes the user's session userRouter.get("/logout", async (req, res) => { console.log("STUB: /user/logout"); // TODO: Stub res.send({ error: "0", data: {}, }); }); // TODO: This should be shared with the frontend, to remove code duplication export enum VocabType { NOMEN = 0, VERB = 1, ADJEKTIV = 2, ADVERB = 3, }; // Gets the user's review queue userRouter.get("/queue", async (req, res) => { console.log("STUB: /user/queue"); // TODO: Stub res.send({ error: "0", data: { queue: [{ german: ["Wein"], hint: "Worte auf '-um' sind meistens NeutrUM", type: VocabType.NOMEN, latin: { grundform: "Vinum", genitiv: "Vini", genus: "Neutrum" }, id: 0 }] }, }); }); // Get ot set the last review results userRouter.get("/lastReview", async (req, res) => { console.log("STUB(get): /user/lastReview"); // TODO: Stub res.send({ error: "0", data: { correct: 6, wrong: 2, }, }); }); userRouter.post("/lastReview", async (req, res) => { console.log("STUB(post): /user/lastReview"); // TODO: Stub res.send({ error: "0", data: {}, }); }); // Get the next level userRouter.get("/nextLevel", async (req, res) => { console.log("STUB: /user/nextLevel"); // TODO: Stub res.send({ error: "0", data: { name: "Test level", desc: "Just a test", level: 3, done: false, }, }); }); // Mark a level as done userRouter.post("/level/:id", async (req, res) => { console.log("STUB(post): /user/level/:id"); // TODO: Stub res.send({ error: "0", data: {}, }); }); // Get the data needed for the dashboard userRouter.post("/dashboard", async (req, res) => { console.log("STUB(post): /user/dashboard"); // TODO: Stub res.send({ error: "0", data: { nextLevel: {}, topTen: {}, lastReview: {}, }, }); }); export default userRouter;