Type Middlewares #499
-
|
Using oak I can define a route like this router.get("/:year", (context) => {
context.response.body = { result: isLeapYear(context.params.year) };
});When trying to split the code export const PerYearMiddleware: Middleware = (context) => {
context.response.body = { result: isLeapYear(context.params.year) };
};I get this error If I understand correctly is because the middleware doesn't have the context that it will run on I tried with export const PerYearMiddleware: Middleware<"/:year"> = (context) => {
context.response.body = { result: isLeapYear(context.params.year) };
};But it didnt work 😔 I'm splitting it so i can test it with https://oakserver.github.io/oak/testing I already have some text written using https://github.com/cmorten/superoak |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
This would help to close UltiRequiem/leap-year-api#4 😢 |
Beta Was this translation helpful? Give feedback.
-
|
Looks like what I was searching for is RouterMiddleware. https://doc.deno.land/https://deno.land/x/[email protected]/mod.ts/~/RouterMiddleware |
Beta Was this translation helpful? Give feedback.
Looks like what I was searching for is RouterMiddleware.
https://doc.deno.land/https://deno.land/x/[email protected]/mod.ts/~/RouterMiddleware