forked from fastify/fastify-nextjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
62 lines (54 loc) · 1.62 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/// <reference types="next" />
import type {
ContextConfigDefault,
FastifyPluginCallback,
FastifyRequest,
FastifySchema,
HTTPMethods
} from 'fastify';
import type { RouteGenericInterface, RouteShorthandOptions } from 'fastify/types/route';
import { NextServer } from 'next/dist/server/next';
import underPressure from 'under-pressure';
declare module 'fastify' {
type FastifyNextCallback = (
app: NextServer,
req: FastifyRequest,
reply: FastifyReply
) => Promise<void>;
interface FastifyInstance<RawServer, RawRequest, RawReply> {
next<
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
ContextConfig = ContextConfigDefault,
SchemaCompiler = FastifySchema
>(
path: string,
opts?:
| (RouteShorthandOptions<
RawServer,
RawRequest,
RawReply,
RouteGeneric,
ContextConfig,
SchemaCompiler
> & {
method?: HTTPMethods;
})
| FastifyNextCallback,
handle?: FastifyNextCallback
): void;
}
interface FastifyReply {
nextRender(path: string): Promise<void>;
nextRenderError(err: any): Promise<void>;
}
}
// Infer options type, because not exported from Next.
type NextServerConstructor = ConstructorParameters<typeof NextServer>[0];
declare namespace fastifyNext {
interface FastifyNextOptions extends NextServerConstructor {
underPressure?: boolean | underPressure.UnderPressureOptions;
noServeAssets?: boolean;
}
}
declare const fastifyNext: FastifyPluginCallback<fastifyNext.FastifyNextOptions>;
export default fastifyNext;