Params property in Context type
I have been make an adapter to integrate my controllers with Oak Router, but i can't get the route params because Context type don't have params property. For exemple:
On adpater, instructions like this works:
const body = context.request.body({ type: "json"}).value
const headers = context.request.headers
But the route params don't work:
const params = context.params don't work because context: Context don't have params property.
The adapter is like:
const adapter => (controller: Controller) => (context: Context) => {}
And its use on router definition, for exemple:
router.get("/car/:id", adapter(getCarController())
Any sugestions to resolve this problem? My sugestion is to implement params property in Context type too.
I had the same issue :disappointed_relieved:
okay solved by using the RouterMiddleware instead of Middleware
Use like this:
import { RouterContext } from 'https://deno.land/x/[email protected]/mod.ts';
const adapter => (controller: Controller) => (context: RouterContext<strig>) => {}
It works for me :)
Use like this:
import { RouterContext } from 'https://deno.land/x/[email protected]/mod.ts'; const adapter => (controller: Controller) => (context: RouterContext<strig>) => {}It works for me :)
Thanks!
(only add some notes, showing my custom case and may be it will be useful for someone) if i correctly understand, it works as type-checker.