@inaiat/fastify-papr
Version:
Fastify Papr Plugin Integration
36 lines (35 loc) • 1.37 kB
TypeScript
import { FastifyPapr, FastifyPaprOptions, ModelRegistration } from "./types.js";
import { BaseSchema, SchemaOptions } from "papr";
import { IndexDescription } from "mongodb";
import { FastifyPluginAsync } from "fastify";
//#region src/fastify-papr-plugin.d.ts
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>;
//#endregion
export { asCollection, _default as default, fastifyPaprPlugin };
//# sourceMappingURL=fastify-papr-plugin.d.ts.map