Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
fastify
GitHub Repository: fastify/point-of-view
Path: blob/main/types/index.d.ts
107 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
};
37
templates?: string | string[];
38
includeViewExtension?: boolean;
39
options?: object;
40
charset?: string;
41
maxCache?: number;
42
production?: boolean;
43
defaultContext?: object;
44
layout?: string;
45
root?: string;
46
viewExt?: string;
47
propertyName?: string;
48
asyncPropertyName?: string;
49
}
50
51
/**
52
* @deprecated Use FastifyViewOptions
53
*/
54
export type PointOfViewOptions = FastifyViewOptions
55
56
export const fastifyView: FastifyView
57
export { fastifyView as default }
58
export const fastifyViewCache: Symbol
59
}
60
61
declare function fastifyView (...params: Parameters<FastifyView>): ReturnType<FastifyView>
62
export = fastifyView
63
64