fix some types

This commit is contained in:
creations 2025-03-26 10:28:26 -04:00
parent f25fe6fab5
commit bb93959ddd
Signed by: creations
GPG key ID: 8F553AA4320FC711
3 changed files with 14 additions and 13 deletions

View file

@ -10,13 +10,13 @@
"cleanup": "rm -rf logs node_modules bun.lockdb"
},
"devDependencies": {
"@eslint/js": "^9.22.0",
"@types/bun": "^1.2.5",
"@eslint/js": "^9.23.0",
"@types/bun": "^1.2.6",
"@types/ejs": "^3.1.5",
"@typescript-eslint/eslint-plugin": "^8.26.1",
"@typescript-eslint/parser": "^8.26.1",
"eslint": "^9.22.0",
"eslint-plugin-prettier": "^5.2.3",
"@typescript-eslint/eslint-plugin": "^8.28.0",
"@typescript-eslint/parser": "^8.28.0",
"eslint": "^9.23.0",
"eslint-plugin-prettier": "^5.2.5",
"eslint-plugin-promise": "^7.2.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-unicorn": "^56.0.1",

View file

@ -93,10 +93,11 @@ class ServerHandler {
}
private async handleRequest(
request: ExtendedRequest,
request: Request,
server: BunServer,
): Promise<Response> {
request.startPerf = performance.now();
const extendedRequest: ExtendedRequest = request as ExtendedRequest;
extendedRequest.startPerf = performance.now();
const pathname: string = new URL(request.url).pathname;
if (pathname.startsWith("/public") || pathname === "/favicon.ico") {
@ -190,11 +191,11 @@ class ServerHandler {
{ status: 406 },
);
} else {
request.params = params;
request.query = query;
extendedRequest.params = params;
extendedRequest.query = query;
response = await routeModule.handler(
request,
extendedRequest,
requestBody,
server,
);
@ -249,7 +250,7 @@ class ServerHandler {
`(${response.status})`,
[
request.url,
`${(performance.now() - request.startPerf).toFixed(2)}ms`,
`${(performance.now() - extendedRequest.startPerf).toFixed(2)}ms`,
ip || "unknown",
],
"90",

2
types/routes.d.ts vendored
View file

@ -7,7 +7,7 @@ type RouteDef = {
type RouteModule = {
handler: (
request: Request,
request: Request | ExtendedRequest,
requestBody: unknown,
server: BunServer,
) => Promise<Response> | Response;