log registered routes
This commit is contained in:
parent
d23bf136d4
commit
8d43fce7d4
5
TODO.md
5
TODO.md
@ -1,22 +1,27 @@
|
||||
# Todo list
|
||||
|
||||
Leaderboards:
|
||||
|
||||
- [ ] ScoreSaber
|
||||
- [ ] BeatLeader
|
||||
- [ ] AccSaber?
|
||||
|
||||
Score fetching:
|
||||
|
||||
- Fetch and store all scores from the websocket
|
||||
- Update every players scores every week so we can ensure we have every score stored. (last 20 pages?)
|
||||
|
||||
Player data fetching:
|
||||
|
||||
- Update player data every hour
|
||||
|
||||
BeatSaver data:
|
||||
|
||||
- API Route: "/beatsaver/maps?hashes=id1,id2, etc"
|
||||
- Fetch map data from their api if we haven't already cached it. Cached maps should last for a week or 2 (longer if ranked?)
|
||||
|
||||
Routes:
|
||||
|
||||
- Leaderboard curve for the given Leaderboard
|
||||
- Player data for the given Leaderboard
|
||||
- Player scores for the given Leaderboard: <br/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Request, Response } from "express";
|
||||
import { NextFunction, Request, Response } from "express";
|
||||
import { Route } from "../route";
|
||||
|
||||
export default class TestRoute extends Route {
|
||||
@ -9,7 +9,7 @@ export default class TestRoute extends Route {
|
||||
});
|
||||
}
|
||||
|
||||
async handle(req: Request, res: Response) {
|
||||
async handle(req: Request, res: Response, next: NextFunction) {
|
||||
res.send("Hello World!");
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Request, Response } from "express";
|
||||
import { NextFunction, Request, Response } from "express";
|
||||
|
||||
type Method = "GET" | "POST" | "PUT" | "DELETE" | "ALL";
|
||||
|
||||
@ -41,7 +41,7 @@ export abstract class Route {
|
||||
* @param req the request
|
||||
* @param res the response
|
||||
*/
|
||||
abstract handle(req: Request, res: Response): void;
|
||||
abstract handle(req: Request, res: Response, next: NextFunction): void;
|
||||
|
||||
/**
|
||||
* Get the path of the route
|
||||
|
@ -8,12 +8,4 @@ export class SsrServer extends Server {
|
||||
routes: [new TestRoute()],
|
||||
});
|
||||
}
|
||||
|
||||
public preInit(): void {
|
||||
console.log("preInit");
|
||||
}
|
||||
|
||||
public postInit(): void {
|
||||
console.log("postInit");
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,13 @@ export default class Server {
|
||||
if (req.method.toUpperCase() !== route.getMethod().toUpperCase()) {
|
||||
return next(); // Skip this method
|
||||
}
|
||||
route.handle(req, res);
|
||||
route.handle(req, res, next);
|
||||
});
|
||||
}
|
||||
console.log(`Registered ${this.routes.length} routes`);
|
||||
for (const route of this.routes) {
|
||||
console.log(` - ${route.getMethod().toUpperCase()} ${route.getPath()}`);
|
||||
}
|
||||
|
||||
// Handle unknown routes
|
||||
this.server.all("*", (req, res) => {
|
||||
|
Loading…
Reference in New Issue
Block a user