UNPKG

940 BTypeScriptView Raw
1import { FastifyPluginOptions, FastifyPluginCallback, FastifyPluginAsync } from './plugin'
2import { LogLevel } from './logger'
3
4/**
5 * FastifyRegister
6 *
7 * Function for adding a plugin to fastify. The options are inferred from the passed in FastifyPlugin parameter.
8 */
9export interface FastifyRegister<T = void> {
10 <Options extends FastifyPluginOptions>(
11 plugin: FastifyPluginCallback<Options>,
12 opts?: FastifyRegisterOptions<Options>
13 ): T;
14 <Options extends FastifyPluginOptions>(
15 plugin: FastifyPluginAsync<Options>,
16 opts?: FastifyRegisterOptions<Options>
17 ): T;
18 <Options extends FastifyPluginOptions>(
19 plugin: FastifyPluginCallback<Options> | FastifyPluginAsync<Options>,
20 opts?: FastifyRegisterOptions<Options>
21 ): T;
22}
23
24export type FastifyRegisterOptions<Options> = (RegisterOptions & Options) | (() => RegisterOptions & Options)
25
26interface RegisterOptions {
27 prefix?: string;
28 logLevel?: LogLevel;
29}
30
\No newline at end of file