Skip to content

Commit

Permalink
add this type to validate function (#64)
Browse files Browse the repository at this point in the history
* add this type to validate function

* fix import
  • Loading branch information
matthyk authored Nov 16, 2021
1 parent f287c61 commit 83c6ad1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
onRequestHookHandler,
preParsingHookHandler,
preValidationHookHandler,
preHandlerHookHandler
preHandlerHookHandler,
FastifyInstance
} from 'fastify'

declare module 'fastify' {
Expand All @@ -18,6 +19,7 @@ declare module 'fastify' {

export interface FastifyBasicAuthOptions {
validate(
this: FastifyInstance,
username: string,
password: string,
req: FastifyRequest,
Expand Down
7 changes: 5 additions & 2 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import fastify, {
onRequestHookHandler,
preParsingHookHandler,
preValidationHookHandler,
preHandlerHookHandler
} from 'fastify'
preHandlerHookHandler,
FastifyInstance
} from 'fastify'
import fastifyBasicAuth from '.'

const app = fastify()
Expand All @@ -17,6 +18,7 @@ app.register(fastifyBasicAuth, {
expectType<string>(password)
expectType<FastifyRequest>(req)
expectType<FastifyReply>(reply)
expectType<FastifyInstance>(this)
},
header: 'x-forwarded-authorization'
})
Expand All @@ -28,6 +30,7 @@ app.register(fastifyBasicAuth, {
expectType<FastifyRequest>(req)
expectType<FastifyReply>(reply)
expectAssignable<(err?: Error) => void>(done)
expectType<FastifyInstance>(this)
}
})

Expand Down

0 comments on commit 83c6ad1

Please sign in to comment.