diff --git a/src/merlee.ts b/src/merlee.ts index 790914f..22d79f7 100644 --- a/src/merlee.ts +++ b/src/merlee.ts @@ -63,7 +63,7 @@ class Merlee { handler(options: HandlerOptions, callback: HandlerCallback) { const { path, method = 'get' } = options; - this.server.on('request', (req: Request, res: Response) => { + this.server.on('request', (req: Request, res: Response) => { // error cannot set headers after they have been sent _static(req, res, this.options.static); @@ -197,7 +197,7 @@ class Merlee { redirect, } as unknown as Response; - const request = { ...req, params, param } as unknown as Request; + const request = { ...req, params, param } as unknown as Request; // request is from router if (typeof options != 'function') { diff --git a/src/types/index.ts b/src/types/index.ts index ce37df4..7167a00 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -7,15 +7,15 @@ export interface Response extends ServerResponse { sendFile: (file: string, status: number) => void; redirect: (path: string) => void; } -export interface Request extends IncomingMessage { +export interface Request extends IncomingMessage { query: unknown; params: Record; param: (name: string) => string; - body?: any; + body?: T; } export interface HandlerCallback { - (req: Request, res: Response): void; + (req: Request, res: Response): void; } type RequestMethod = @@ -36,7 +36,7 @@ export interface HandlerOptions { export type NextFunction = (err?: Error) => void; export type HandlerFunction = ( - req: Request, + req: Request, res: Response, next?: NextFunction ) => void;