import { FastifyPluginAsync } from 'fastify'; import { Scope } from 'go-go-scope'; /** * Fastify adapter for go-go-scope * Provides request-scoped structured concurrency for Fastify applications */ declare module "fastify" { interface FastifyInstance { scope: Scope; } interface FastifyRequest { scope: Scope; } } interface FastifyGoGoScopeOptions { /** Root scope name */ name?: string; /** Default timeout for all requests */ timeout?: number; } /** * Fastify plugin for go-go-scope integration * * @example * ```typescript * import fastify from 'fastify' * import { fastifyGoGoScope } from '@go-go-scope/adapter-fastify' * * const app = fastify() * await app.register(fastifyGoGoScope, { metrics: true }) * * app.get('/users/:id', async (request, reply) => { * const [err, user] = await request.scope.task( * () => fetchUser(request.params.id), * { retry: 'exponential', timeout: 5000 } * ) * * if (err) { * return reply.code(500).send({ error: err.message }) * } * return user * }) * ``` */ declare const fastifyGoGoScope: FastifyPluginAsync; export { fastifyGoGoScope }; export type { FastifyGoGoScopeOptions };