feat: Stub more APIs

This commit is contained in:
Alexander Polynomdivision 2018-09-23 21:52:29 +02:00
parent 62a81ddeeb
commit a7dc7464a1
2 changed files with 27 additions and 10 deletions

View File

@ -13,4 +13,4 @@ dev:
.PHONY: start .PHONY: start
start: dev start: dev
node dist/backend/src/main.js node dist/bundle.js

View File

@ -39,19 +39,22 @@ authRouter.get("/class/:id/topTen", async (req, res) => {
} }
console.log("Stub: /auth/class/:id/topTen"); console.log("Stub: /auth/class/:id/topTen");
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: Implement // TODO: Implement
res.send({ res.send({
error: "0", error: "0",
data: { data: {
topTen: [{ topTen: users,
username: "User1",
level: 5,
score: 200,
}, {
username: "User2",
level: 4,
score: 100,
}],
} }
}); });
}); });
@ -86,6 +89,20 @@ authRouter.get("/level/:id/vocab", async (req, res) => {
} }
}); });
}); });
authRouter.get("/user/nextLevel", async (req, res) => {
console.log("Stub: /auth/user/nextLevel");
res.send({
error: "0",
data: {
name: "Test level",
desc: "Just a test",
level: 3,
done: false,
},
});
});
const app = express(); const app = express();
app.use(bodyparser.json()); app.use(bodyparser.json());