log registered routes
This commit is contained in:
parent
d23bf136d4
commit
8d43fce7d4
9
TODO.md
9
TODO.md
@ -1,23 +1,28 @@
|
|||||||
# Todo list
|
# Todo list
|
||||||
|
|
||||||
Leaderboards:
|
Leaderboards:
|
||||||
|
|
||||||
- [ ] ScoreSaber
|
- [ ] ScoreSaber
|
||||||
- [ ] BeatLeader
|
- [ ] BeatLeader
|
||||||
- [ ] AccSaber?
|
- [ ] AccSaber?
|
||||||
|
|
||||||
Score fetching:
|
Score fetching:
|
||||||
|
|
||||||
- Fetch and store all scores from the websocket
|
- 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?)
|
- Update every players scores every week so we can ensure we have every score stored. (last 20 pages?)
|
||||||
|
|
||||||
Player data fetching:
|
Player data fetching:
|
||||||
|
|
||||||
- Update player data every hour
|
- Update player data every hour
|
||||||
|
|
||||||
BeatSaver data:
|
BeatSaver data:
|
||||||
|
|
||||||
- API Route: "/beatsaver/maps?hashes=id1,id2, etc"
|
- 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?)
|
- 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:
|
Routes:
|
||||||
|
|
||||||
- Leaderboard curve for the given Leaderboard
|
- Leaderboard curve for the given Leaderboard
|
||||||
- Player data for the given Leaderboard
|
- Player data for the given Leaderboard
|
||||||
- Player scores for the given Leaderboard: <br/>
|
- Player scores for the given Leaderboard: <br/>
|
||||||
add a query to add extra score data from BeatLeader (eg: per hand acc, etc)
|
add a query to add extra score data from BeatLeader (eg: per hand acc, etc)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Request, Response } from "express";
|
import { NextFunction, Request, Response } from "express";
|
||||||
import { Route } from "../route";
|
import { Route } from "../route";
|
||||||
|
|
||||||
export default class TestRoute extends 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!");
|
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";
|
type Method = "GET" | "POST" | "PUT" | "DELETE" | "ALL";
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export abstract class Route {
|
|||||||
* @param req the request
|
* @param req the request
|
||||||
* @param res the response
|
* @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
|
* Get the path of the route
|
||||||
|
@ -8,12 +8,4 @@ export class SsrServer extends Server {
|
|||||||
routes: [new TestRoute()],
|
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()) {
|
if (req.method.toUpperCase() !== route.getMethod().toUpperCase()) {
|
||||||
return next(); // Skip this method
|
return next(); // Skip this method
|
||||||
}
|
}
|
||||||
route.handle(req, res);
|
route.handle(req, res, next);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(`Registered ${this.routes.length} routes`);
|
console.log(`Registered ${this.routes.length} routes`);
|
||||||
|
for (const route of this.routes) {
|
||||||
|
console.log(` - ${route.getMethod().toUpperCase()} ${route.getPath()}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle unknown routes
|
// Handle unknown routes
|
||||||
this.server.all("*", (req, res) => {
|
this.server.all("*", (req, res) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user