UNPKG

2.14 kBTypeScriptView Raw
1import { FastifyPluginOptions, FastifyPluginCallback, FastifyPluginAsync } from './plugin'
2import { LogLevel } from './logger'
3import { FastifyInstance } from './instance'
4import { RawServerBase } from './utils'
5import { FastifyBaseLogger, FastifyTypeProvider, RawServerDefault } from '../fastify'
6
7export interface RegisterOptions {
8 prefix?: string;
9 logLevel?: LogLevel;
10 logSerializers?: Record<string, (value: any) => string>;
11}
12
13export type FastifyRegisterOptions<Options> = (RegisterOptions & Options) | ((instance: FastifyInstance) => RegisterOptions & Options)
14
15/**
16 * FastifyRegister
17 *
18 * Function for adding a plugin to fastify. The options are inferred from the passed in FastifyPlugin parameter.
19 */
20export interface FastifyRegister<T = void, RawServer extends RawServerBase = RawServerDefault, TypeProviderDefault extends FastifyTypeProvider = FastifyTypeProvider, LoggerDefault extends FastifyBaseLogger = FastifyBaseLogger> {
21 <Options extends FastifyPluginOptions, Server extends RawServerBase = RawServer, TypeProvider extends FastifyTypeProvider = TypeProviderDefault, Logger extends FastifyBaseLogger = LoggerDefault>(
22 plugin: FastifyPluginCallback<Options, Server, TypeProvider, Logger>,
23 opts?: FastifyRegisterOptions<Options>
24 ): T;
25 <Options extends FastifyPluginOptions, Server extends RawServerBase = RawServer, TypeProvider extends FastifyTypeProvider = TypeProviderDefault, Logger extends FastifyBaseLogger = LoggerDefault>(
26 plugin: FastifyPluginAsync<Options, Server, TypeProvider, Logger>,
27 opts?: FastifyRegisterOptions<Options>
28 ): T;
29 <Options extends FastifyPluginOptions, Server extends RawServerBase = RawServer, TypeProvider extends FastifyTypeProvider = TypeProviderDefault, Logger extends FastifyBaseLogger = LoggerDefault>(
30 plugin: FastifyPluginCallback<Options, Server, TypeProvider, Logger> | FastifyPluginAsync<Options, Server, TypeProvider, Logger> | Promise<{ default: FastifyPluginCallback<Options, Server, TypeProvider, Logger> }> | Promise<{ default: FastifyPluginAsync<Options, Server, TypeProvider, Logger> }>,
31 opts?: FastifyRegisterOptions<Options>
32 ): T;
33}
34
\No newline at end of file