diff --git a/.gitignore b/.gitignore index 00e19b3..b5493ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ src/responseHandler.js src/route.ts -node_modules \ No newline at end of file +node_modules +route.ts \ No newline at end of file diff --git a/src/handleRequest.ts b/src/handleRequest.ts index 1be2036..0c8f7bf 100644 --- a/src/handleRequest.ts +++ b/src/handleRequest.ts @@ -51,7 +51,6 @@ export default async function handleRequest(req: Request, server: Server, url: U if (diesel.hasMiddleware) { // first run global midl const globalMiddleware = diesel.globalMiddlewares - for (let i = 0; i < globalMiddleware.length; i++) { const result = await globalMiddleware[i](ctx, server); if (result) return result; diff --git a/src/main.ts b/src/main.ts index ad27165..dc52586 100644 --- a/src/main.ts +++ b/src/main.ts @@ -454,4 +454,8 @@ export default class Diesel { this.addRoute("DELETE", path, handlers); return this; } + options(path: string, ...handlers: handlerFunction[]): this { + this.addRoute("OPTIONS", path, handlers); + return this; + } }