feat: Implement the new /dashboard API

This commit is contained in:
Alexander Polynomdivision
2018-09-24 18:29:29 +02:00
parent 7339e1ccac
commit 24f35be058
7 changed files with 127 additions and 143 deletions

View File

@@ -114,16 +114,35 @@ userRouter.post("/level/:id", async (req, res) => {
});
// Get the data needed for the dashboard
userRouter.post("/dashboard", async (req, res) => {
userRouter.get("/dashboard", async (req, res) => {
console.log("STUB(post): /user/dashboard");
let users: any[] = [];
let nr = 10;
for (let i = 0; i < 10; i++)
users = users.concat({
username: `Test User ${i}`,
score: 100 * i,
level: Math.floor(Math.random() * Math.floor(10)),
nr: nr--,
});
// TODO: Stub
res.send({
error: "0",
error: "200",
data: {
nextLevel: {},
topTen: {},
lastReview: {},
nextLevel: {
name: "Test level",
desc: "Just a test",
level: 3,
done: false,
},
topTen: users,
lastReview: {
correct: 0,
wrong: 0,
},
},
});
});