Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
fastify
GitHub Repository: fastify/point-of-view
Path: blob/main/types/index.d.ts
162 views
1
import { FastifyPluginAsync } from 'fastify'
2
3
declare module 'fastify' {
4
5
interface RouteSpecificOptions {
6
layout?: string;
7
}
8
9
interface FastifyReply {
10
view<T extends { [key: string]: any; }>(page: string, data: T, opts?: RouteSpecificOptions): FastifyReply;
11
view(page: string, data?: object, opts?: RouteSpecificOptions): FastifyReply;
12
viewAsync<T extends { [key: string]: any; }>(page: string, data: T, opts?: RouteSpecificOptions): Promise<string>;
13
viewAsync(page: string, data?: object, opts?: RouteSpecificOptions): Promise<string>;
14
}
15
16
interface FastifyInstance {
17
view<T extends { [key: string]: any; }>(page: string, data: T, opts?: RouteSpecificOptions): Promise<string>;
18
view(page: string, data?: object, opts?: RouteSpecificOptions): Promise<string>;
19
}
20
}
21
22
type FastifyView = FastifyPluginAsync<fastifyView.FastifyViewOptions>
23
24
declare namespace fastifyView {
25
export interface FastifyViewOptions {
26
engine: {
27
ejs?: any;
28
eta?: any;
29
nunjucks?: any;
30
pug?: any;
31
handlebars?: any;
32
mustache?: any;
33
twig?: any;
34
liquid?: any;
35
dot?: any;
36
squirrelly?: any;
37
};
38
templates?: string | string[];
39
includeViewExtension?: boolean;
40
options?: object;
41
charset?: string;
42
maxCache?: number;
43
production?: boolean;
44
defaultContext?: object;
45
layout?: string;
46
root?: string;
47
viewExt?: string;
48
propertyName?: string;
49
asyncPropertyName?: string;
50
}
51
52
/**
53
* @deprecated Use FastifyViewOptions
54
*/
55
export type PointOfViewOptions = FastifyViewOptions
56
57
export const fastifyView: FastifyView
58
export { fastifyView as default }
59
export const fastifyViewCache: Symbol
60
}
61
62
declare function fastifyView (...params: Parameters<FastifyView>): ReturnType<FastifyView>
63
export = fastifyView
64
65