Skip to content

Commit

Permalink
Merge pull request #69 from mcchrish/patch-1
Browse files Browse the repository at this point in the history
Add typings for messages option
  • Loading branch information
mcollina authored Sep 13, 2019
2 parents 14c05e4 + ea0b3b6 commit 0ef18f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ declare interface FastifyJWTOptions {
decode?: jwt.DecodeOptions;
sign?: jwt.SignOptions;
verify?: jwt.VerifyOptions;
messages?: {
badRequestErrorMessage?: string;
noAuthorizationInHeaderMessage?: string;
authorizationTokenExpiredMessage?: string;
authorizationTokenInvalid?: ((err: Error) => string) | string;
}
}

declare const fastifyJWT: fastify.Plugin<http.Server, http.IncomingMessage, http.ServerResponse, FastifyJWTOptions>;
Expand Down
8 changes: 7 additions & 1 deletion type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ app.register(fastifyJwt, {
},
decode: {
complete: true
}
},
messages: {
badRequestErrorMessage: 'Bad Request',
noAuthorizationInHeaderMessage: 'No Header',
authorizationTokenExpiredMessage: 'Token Expired',
authorizationTokenInvalid: (err) => `${err.message}`
}
});

app.addHook("preHandler", async (request, reply) =>
Expand Down

0 comments on commit 0ef18f3

Please sign in to comment.