From 68816467ed27658b5551d93ecf82f440577eb2ec Mon Sep 17 00:00:00 2001 From: Francis Daigle Date: Thu, 20 May 2021 14:25:58 -0700 Subject: [PATCH] Add missing options --- types/index.d.ts | 6 +++++- types/index.test-d.ts | 11 +++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index a67eab8..4d4bc23 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -26,10 +26,14 @@ declare module 'fastify' { } declare const fastifyGuard: FastifyPluginCallback<{ - errorHandler( + errorHandler?( result: createHttpError.HttpError, request: FastifyRequest, reply: FastifyReply ): any + requestProperty?: string + roleProperty?: string + scopeProperty?: string }> + export default fastifyGuard diff --git a/types/index.test-d.ts b/types/index.test-d.ts index b1a053e..3fab22f 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -12,8 +12,11 @@ const fastify = Fastify() fastify.register(fastifyGuard, { errorHandler: (result, req, reply) => { - return reply.send('Custom error message') - } + return reply.send('string') + }, + requestProperty: 'string', + roleProperty: 'string', + scopeProperty: 'string' }) ;(request: FastifyRequest, reply: FastifyReply) => { @@ -26,5 +29,5 @@ fastify.register(fastifyGuard, { ) } -expectType(fastify.guard.role(['user'])) -expectType(fastify.guard.scope(['read'])) +expectType(fastify.guard.role(['string'])) +expectType(fastify.guard.scope(['string']))