From 6a7a4829247cbc0251d9b215972f0165c42a354a Mon Sep 17 00:00:00 2001 From: Philipp Gfeller Date: Thu, 5 Dec 2019 23:15:34 +0100 Subject: [PATCH] fix: add user to FastifyRequest typings (#74) (#75) * fix: add user to FastifyRequest typings (#74) * tests: add test for user type on request --- index.d.ts | 1 + type.test.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/index.d.ts b/index.d.ts index e933397..f29d347 100644 --- a/index.d.ts +++ b/index.d.ts @@ -55,6 +55,7 @@ declare module 'fastify' { options: jwt.VerifyOptions, callback: JWTTypes.VerifyCallback, ): void; + user: JWTTypes.SignPayloadType; } } diff --git a/type.test.ts b/type.test.ts index 9f2d2dd..2e02567 100644 --- a/type.test.ts +++ b/type.test.ts @@ -40,5 +40,6 @@ app.post('/signup', async (req, reply) => { const token = app.jwt.sign({ user: "userName" }); let data = await app.jwt.verify(token); + const user = req.user; reply.send({ token }); });