-
-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
In this example the middleware is "wrongly" classed as a Handler and not a MiddlewareFunc
(method) BunServer.use(middleware: Handler): void
app.use((req: BunRequest, res: BunResponse, next: ((err?: Error | undefined) => {}) | undefined) => {
console.log("middlewares called");
next!(); // Results in next() possible undefined
})What it should classify it as src/server/request.ts
11 export type MiddlewareFunc = (
12 req: Request,
13 res: BunResponse,
14 next: (err?: Error) => {}
15 ) => void;The errorhandler in src/server/server.ts also switches the err and next function around based on the type definitions from src/server/request.ts
4 export type Handler = (
5 req: BunRequest,
6 res: BunResponse,
7 next?: (err?: Error) => {},
8 err?: Error
9 ) => void | Promise<any>;src/server/server.ts
229 that.errorHandlers.forEach((handler) => {
230 // * no request object pass to error handler
231 handler.apply(that, [null, res, err, next]);
232 });Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels