Howard86 / next-api-handler

lightweight nextjs api handler wrapper, portable & configurable for serverless environment
https://next-api-handler.vercel.app
Other
50 stars 1 forks source link

Bugfix/fix-middleware-type-declaration #5

Closed Howard86 closed 3 years ago

Howard86 commented 3 years ago

Bug fix: fix incorrect type declaration of NextApiRequestWithMiddleware

when using router.use, it will not allow to inject middleware type definition

e.g. can use the following (optional)

type User = {
  name: string
}
router.use<User>(req => ({name: "USER"}))
router.get(req: NextApiRequestWithMiddleware<User> => req.middlware.name)