fix some types
This commit is contained in:
parent
f25fe6fab5
commit
bb93959ddd
3 changed files with 14 additions and 13 deletions
12
package.json
12
package.json
|
@ -10,13 +10,13 @@
|
||||||
"cleanup": "rm -rf logs node_modules bun.lockdb"
|
"cleanup": "rm -rf logs node_modules bun.lockdb"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.22.0",
|
"@eslint/js": "^9.23.0",
|
||||||
"@types/bun": "^1.2.5",
|
"@types/bun": "^1.2.6",
|
||||||
"@types/ejs": "^3.1.5",
|
"@types/ejs": "^3.1.5",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
"@typescript-eslint/eslint-plugin": "^8.28.0",
|
||||||
"@typescript-eslint/parser": "^8.26.1",
|
"@typescript-eslint/parser": "^8.28.0",
|
||||||
"eslint": "^9.22.0",
|
"eslint": "^9.23.0",
|
||||||
"eslint-plugin-prettier": "^5.2.3",
|
"eslint-plugin-prettier": "^5.2.5",
|
||||||
"eslint-plugin-promise": "^7.2.1",
|
"eslint-plugin-promise": "^7.2.1",
|
||||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||||
"eslint-plugin-unicorn": "^56.0.1",
|
"eslint-plugin-unicorn": "^56.0.1",
|
||||||
|
|
|
@ -93,10 +93,11 @@ class ServerHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleRequest(
|
private async handleRequest(
|
||||||
request: ExtendedRequest,
|
request: Request,
|
||||||
server: BunServer,
|
server: BunServer,
|
||||||
): Promise<Response> {
|
): Promise<Response> {
|
||||||
request.startPerf = performance.now();
|
const extendedRequest: ExtendedRequest = request as ExtendedRequest;
|
||||||
|
extendedRequest.startPerf = performance.now();
|
||||||
|
|
||||||
const pathname: string = new URL(request.url).pathname;
|
const pathname: string = new URL(request.url).pathname;
|
||||||
if (pathname.startsWith("/public") || pathname === "/favicon.ico") {
|
if (pathname.startsWith("/public") || pathname === "/favicon.ico") {
|
||||||
|
@ -190,11 +191,11 @@ class ServerHandler {
|
||||||
{ status: 406 },
|
{ status: 406 },
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
request.params = params;
|
extendedRequest.params = params;
|
||||||
request.query = query;
|
extendedRequest.query = query;
|
||||||
|
|
||||||
response = await routeModule.handler(
|
response = await routeModule.handler(
|
||||||
request,
|
extendedRequest,
|
||||||
requestBody,
|
requestBody,
|
||||||
server,
|
server,
|
||||||
);
|
);
|
||||||
|
@ -249,7 +250,7 @@ class ServerHandler {
|
||||||
`(${response.status})`,
|
`(${response.status})`,
|
||||||
[
|
[
|
||||||
request.url,
|
request.url,
|
||||||
`${(performance.now() - request.startPerf).toFixed(2)}ms`,
|
`${(performance.now() - extendedRequest.startPerf).toFixed(2)}ms`,
|
||||||
ip || "unknown",
|
ip || "unknown",
|
||||||
],
|
],
|
||||||
"90",
|
"90",
|
||||||
|
|
2
types/routes.d.ts
vendored
2
types/routes.d.ts
vendored
|
@ -7,7 +7,7 @@ type RouteDef = {
|
||||||
|
|
||||||
type RouteModule = {
|
type RouteModule = {
|
||||||
handler: (
|
handler: (
|
||||||
request: Request,
|
request: Request | ExtendedRequest,
|
||||||
requestBody: unknown,
|
requestBody: unknown,
|
||||||
server: BunServer,
|
server: BunServer,
|
||||||
) => Promise<Response> | Response;
|
) => Promise<Response> | Response;
|
||||||
|
|
Loading…
Add table
Reference in a new issue