Eomm / fastify-raw-body

Request raw body
MIT License
44 stars 10 forks source link

Add missing route config type #50

Closed FabianFrank closed 1 year ago

FabianFrank commented 1 year ago

as of fastify 4.19.0 route configs have to be typed explicitly, without this change with fastify 4.19.0 and above a route like

f.get("/foo", { config: { rawBody: true } }, () => {})

produces the following error:

Type '{ auth: "public"; rawBody: true; }' is not assignable to type 'Omit<FastifyContextConfig & FastifyRouteConfig, "url" | "method">'.
  Object literal may only specify known properties, and 'rawBody' does not exist in type 'Omit<FastifyContextConfig & FastifyRouteConfig, "url" | "method">'.

See https://github.com/fastify/fastify-rate-limit/pull/306 for a similar fix in an official fastify plugin.

FabianFrank commented 1 year ago

Could you update the test/types/types.test.ts file too?

done