diff --git a/package.json b/package.json index 4288d28..0878df3 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/server.ts b/src/server.ts index 1f8985c..3f78cb5 100644 --- a/src/server.ts +++ b/src/server.ts @@ -93,10 +93,11 @@ class ServerHandler { } private async handleRequest( - request: ExtendedRequest, + request: Request, server: BunServer, ): Promise { - 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", diff --git a/types/routes.d.ts b/types/routes.d.ts index 5517e0d..9d9d809 100644 --- a/types/routes.d.ts +++ b/types/routes.d.ts @@ -7,7 +7,7 @@ type RouteDef = { type RouteModule = { handler: ( - request: Request, + request: Request | ExtendedRequest, requestBody: unknown, server: BunServer, ) => Promise | Response;