I have this code
const keren = async (ctx: Context, next: any) => {
console.log('keren');
await next();
}
const mantap = async (ctx: Context, next: any) => {
console.log('mantap');
await next();
}
router.get('/owkowkkow',keren,mantap,(ctx: Context) => {
ctx.response.body = "wkwkwkw";
});
it work's good , but i want to use keren and mantap in one variable called onevar
so the code gonna be like this :
router.get('/owkowkkow',onevar,(ctx: Context) => {
ctx.response.body = "wkwkwkw";
});
how to do that? is it can?
Oak comes with compose middleware that will allow you to compose a middleware from multiple middlewares
import { composeMiddleware as compose } from "https://deno.land/x/oak/mod.ts";
const onevar = compose([
async (ctx: Context, next: any) => {
console.log('keren');
await next();
},
async (ctx: Context, next: any) => {
console.log('mantap');
await next();
}
])
router.get('/owkowkkow',onevar,(ctx: Context) => {
ctx.response.body = "wkwkwkw";
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With