/
render.d.ts
76 lines (70 loc) · 2.76 KB
/
render.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* NuxtOptionsRender
* Documentation: https://nuxtjs.org/api/configuration-render
* https://ssr.vuejs.org/api/#renderer-options
* https://github.com/expressjs/compression#readme
* https://github.com/expressjs/serve-static#readme
* https://github.com/jshttp/etag#readme
*/
import { ServerResponse } from 'http'
import { CompressionOptions } from 'compression'
import { IncomingMessage } from 'connect'
import { Options as EtagOptions } from 'etag'
import { ServeStaticOptions } from 'serve-static'
import { BundleRendererOptions } from 'vue-server-renderer'
import { NuxtOptionsServerMiddleware } from './server-middleware'
type NuxtEtagOptions = EtagOptions & {
hash?: (html: string) => string
}
type ServePlaceholderHandler = 'default' | 'css' | 'html' | 'js' | 'json' | 'map' | 'plain' | 'image'
interface ServePlaceholderOptions {
handlers?: Record<string, ServePlaceholderHandler | null | false>
mimes?: Record<ServePlaceholderHandler, string | false | undefined>
noCache?: boolean
placeholders?: Record<ServePlaceholderHandler, string | Buffer | false>
skipUnknown?: boolean
statusCode?: false | number
}
type CspPolicyName = 'child-src' | 'connect-src' | 'default-src' | 'font-src' | 'frame-src' | 'img-src' | 'manifest-src' | 'media-src' | 'object-src' | 'prefetch-src' | 'script-src' | 'script-src-elem' | 'script-src-attr' | 'style-src' | 'style-src-elem' | 'style-src-attr' | 'worker-src' | 'base-uri' | 'plugin-types' | 'sandbox' | 'form-action' | 'frame-ancestors' | 'navigate-to' | 'report-uri' | 'report-to' | 'block-all-mixed-content' | 'referrer' | 'require-sri-for' | 'trusted-types' | 'upgrade-insecure-requests'
interface CspOptions {
addMeta?: boolean
allowedSources?: string[]
hashAlgorithm?: string
policies?: Partial<Record<CspPolicyName, string[]>>
reportOnly?: boolean
unsafeInlineCompatibility?: boolean
}
interface PreloadFile {
asType: 'script' | 'style' | 'font'
extension: string
file: string
fileWithoutQuery: string
}
export interface NuxtOptionsRender {
bundleRenderer?: BundleRendererOptions
compressor?: CompressionOptions | NuxtOptionsServerMiddleware | false
csp?: boolean | CspOptions
crossorigin?: 'anonymous' | 'use-credentials' | ''
dist?: ServeStaticOptions
etag?: NuxtEtagOptions | false
fallback?: {
dist?: ServePlaceholderOptions
static?: ServePlaceholderOptions
}
http2?: {
push?: boolean
shouldPush?: boolean
pushAssets?: (
req: IncomingMessage,
res: ServerResponse,
publicPath: string,
preloadFiles: PreloadFile[]
) => string[]
}
injectScripts?: boolean
asyncScripts?: boolean
resourceHints?: boolean
ssr?: boolean
ssrLog?: boolean | 'collapsed'
static?: ServeStaticOptions | false
}