UNPKG

@inaiat/fastify-papr

Version:
35 lines (32 loc) 1.3 kB
import { FastifyPluginAsync } from 'fastify'; import { IndexDescription } from 'mongodb'; import { BaseSchema, SchemaOptions } from 'papr'; import { FastifyPapr, FastifyPaprOptions, ModelRegistration } from './types.js'; declare module 'fastify' { interface FastifyInstance { /** * Papr models accessible through the fastify instance * Models can be accessed directly or through a named database connection */ papr: FastifyPapr; } } /** * Helper function to create a model registration * @param name Collection name * @param schema Papr schema definition with options * @param indexes Optional MongoDB indexes to create * @returns A model registration object */ declare const asCollection: <TSchema extends BaseSchema>(name: string, schema: [TSchema, SchemaOptions<Partial<TSchema>>], indexes?: IndexDescription[]) => ModelRegistration; /** * Main Fastify plugin for Papr integration * Registers models to MongoDB and decorates fastify with them */ declare const fastifyPaprPlugin: FastifyPluginAsync<FastifyPaprOptions>; /** * Default export as a Fastify plugin * Compatible with Fastify v4 and v5 */ declare const _default: FastifyPluginAsync<FastifyPaprOptions>; export { asCollection, _default as default, fastifyPaprPlugin };