Closed Snarloff closed 6 months ago
declare module "fastify" {
// eslint-disable-next-line @typescript-eslint/no-empty-interface -- MUST BE AN INTERFACE
interface FastifyInstance
extends FastifyJwtNamespace<{ namespace: "admin" }> {
authenticate: (
namespace: "admin" | "user"
) => (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
}
interface FastifyRequest {
adminJwtVerify: FastifyRequest["jwtVerify"];
adminJwtDecode: FastifyRequest["jwtDecode"];
}
interface FastifyReply {
adminJwtSign: FastifyReply["jwtSign"];
}
}
Prerequisites
Issue
I need to use two methods to create JWTs with different configurations. I saw that there is a "namespace" for this. However, I receive the error error: TypeError: r.app.adminJwtSign is not a function when trying to use the admin namespace function. Typescript is understanding the typing, it's just not working
Used:
My App
I am trying to use "app." because "reply.adminJwtSign" gives a typescript error
error: TypeError: r.app.adminJwtSign is not a function