diff --git a/types/types.d.ts b/types/types.d.ts index 031b050..dced83d 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -4,6 +4,11 @@ import { FastifyPluginCallback } from 'fastify'; import type * as Fastify from 'fastify'; declare module 'fastify' { + interface FastifyInstance { + decryptSession = FastifyRequest>(sessionId: string, request: Request, cookieOpts: FastifySessionPlugin.CookieOptions, callback: Callback): void; + decryptSession = FastifyRequest>(sessionId: string, request: Request, callback: Callback): void; + } + interface FastifyRequest { /** Allows to access or modify the session data. */ session: Fastify.Session; diff --git a/types/types.test-d.ts b/types/types.test-d.ts index b1ec9f9..3352ecb 100644 --- a/types/types.test-d.ts +++ b/types/types.test-d.ts @@ -62,6 +62,12 @@ app.register(plugin, { expectError(app.register(plugin, {})); +expectError(app.decryptSession('sessionId', {}, () => ({}))) +app.decryptSession<{hello: 'world'}>('sessionId', { hello: 'world' }, () => ({})) +app.decryptSession<{hello: 'world'}>('sessionId', { hello: 'world' }, { domain: '/' }, () => ({})) +app.decryptSession('sessionId', {}, () => ({})) +app.decryptSession('sessionId', {}, { domain: '/' }, () => ({})) + app.route({ method: 'GET', url: '/',