Created the achievements.ts route
This commit is contained in:
parent
8ef5e66bd4
commit
8eabeeacd4
19
api/routes/achievements.ts
Normal file
19
api/routes/achievements.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import {Response, Router} from "express";
|
||||
import {AuthenticatedRequest} from "../middlewares/authenticate";
|
||||
import {getAchievements, getStatistics} from "../../controller/achievement";
|
||||
|
||||
const app = Router();
|
||||
|
||||
app.get("/:guildId", async (req: AuthenticatedRequest, res: Response) => {
|
||||
res.json(await getStatistics(req.params.guildId));
|
||||
});
|
||||
|
||||
app.get("/:guildId/:categoryId", (req: AuthenticatedRequest, res: Response) => {
|
||||
getAchievements(req.params.guildId, parseInt(req.params.categoryId)).then((achievements) => {
|
||||
res.json(achievements);
|
||||
}).catch(() => {
|
||||
res.status(500).json({message: "An internal error occurred"});
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = app;
|
Loading…
x
Reference in New Issue
Block a user