-
So I want to create a controller with a route like this. With normal fastify, I was able to add a generic so I could know that @Controller({ route: "/rules" })
export default class RuleController {
@GET({
url: "/:id", options: {
schema: {
params: Type.Required(Type.Object({
id: Type.String()
}))
}
}
})
async getRule(req: FastifyRequest, res: FastifyReply) {
const { id }: { id: string } = <any>req.params
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
L2jLiga
Jul 21, 2021
Replies: 1 comment 1 reply
-
Hi there, I think you are asking about specifying generics for FastifyRequest, the answer is @Controller({ route: "/rules" })
export default class RuleController {
@GET({
url: "/:id", options: {
schema: {
params: Type.Required(Type.Object({
id: Type.String()
}))
}
}
})
async getRule(req: FastifyRequest<{ Params: { id: string } }>, res: FastifyReply) {
const { id }: { id: string } = <any>req.params
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
oof2win2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there, I think you are asking about specifying generics for FastifyRequest, the answer is