koajs / koa-body

koa body parser middleware
MIT License
947 stars 131 forks source link

Provide generic type params #197

Open gao-sun opened 3 years ago

gao-sun commented 3 years ago

Currently the return type of koaBody() has been fixed to Koa.Middleware<{}, {}>, which will be problematic if we would like to provide a different type combo, e.g.:

koaBody<{ userId: string }, ContextT, { status: number }>()

this pr will fix this issue by providing generic type params:

image

since koaBody() will inject body and files into ctx.request directly, it'll be fine to just keep the same input type combo for the return middleware function.

gao-sun commented 3 years ago

@MarkHerhold would you mind to take a look? thanks

DavidTanner commented 2 years ago

@MarkHerhold @dlau I would like these to be merged in as well

MarkHerhold commented 1 year ago

This should be at least partially addressed by #213

DavidTanner commented 1 year ago

I'll check that out