Middlewares
Middleware is a function which is called before the actual request handler.
# Execute the built-in Deno task
deno task create:module -t middleware -n checkAuth --template blank.tsimport { type RouterContext } from "oak";
// If this is a global middleware, do not add arguments to the factory function.
export default () =>
async (ctx: RouterContext<string>, next: () => Promise<unknown>) => {
// Your logic here...
// Continue to the next middleware
await next();
};
{
"sequence": ["checkAuth.ts"],
"excludes": ["checkAuth.ts"]
}
Last updated