@webjsdev/server 0.8.11 → 0.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +19 -0
- package/package.json +5 -2
- package/src/actions.js +112 -11
- package/src/base-path.js +149 -0
- package/src/dev.js +262 -23
- package/src/importmap.js +54 -3
- package/src/redirects.js +389 -0
- package/src/route-types.js +176 -0
- package/src/sitemap.js +161 -0
- package/src/ssr.js +108 -7
- package/src/testing.js +400 -0
- package/src/vendor.js +143 -6
- package/webjs-config.schema.json +147 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://webjs.dev/schemas/webjs-config.schema.json",
|
|
4
|
+
"title": "webjs config block",
|
|
5
|
+
"description": "Schema for the `webjs` object in a webjs app's package.json. Each key maps to a documented server reader. An unknown key is flagged (additionalProperties is false) so a typo no longer silently falls back to the default.",
|
|
6
|
+
"$comment": "Single source of truth lives in THREE co-located places that must stay in lockstep: this schema, the TS type at packages/core/src/webjs-config.d.ts, and the server reader functions (readElideEnabled in dev.js, compileHeaderRules in headers.js, compileRedirectRules / readTrailingSlashPolicy in redirects.js, readBasePath in base-path.js, readCspConfig in csp.js, readBodyLimits / computeServerTimeouts in body-limit.js). Adding a webjs.* key means updating all three. See packages/server/AGENTS.md for the one documented procedure.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"elide": {
|
|
11
|
+
"description": "Display-only and inert-route dead-JS elision switch. Default true. Set to false to ship every module's JS app-wide, as before the feature existed. Read by readElideEnabled in dev.js; the WEBJS_ELIDE env override wins over this.",
|
|
12
|
+
"type": "boolean",
|
|
13
|
+
"default": true
|
|
14
|
+
},
|
|
15
|
+
"headers": {
|
|
16
|
+
"description": "Per-path response-header rules, shaped like Next's. Each rule pairs a URLPattern source against header directives. Read by compileHeaderRules in headers.js.",
|
|
17
|
+
"type": "array",
|
|
18
|
+
"items": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"required": ["source", "headers"],
|
|
21
|
+
"properties": {
|
|
22
|
+
"source": {
|
|
23
|
+
"description": "Path pattern matched with the native URLPattern API (so :param and :rest* syntax works).",
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"headers": {
|
|
27
|
+
"description": "Header directives applied on a match.",
|
|
28
|
+
"type": "array",
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"required": ["key"],
|
|
32
|
+
"properties": {
|
|
33
|
+
"key": {
|
|
34
|
+
"description": "Header name, e.g. X-Frame-Options.",
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
"value": {
|
|
38
|
+
"description": "Header value. A null or false value REMOVES the header on a match, the escape hatch that drops a secure default on a path. true is intentionally not allowed (it would stringify to the literal 'true').",
|
|
39
|
+
"oneOf": [{ "type": ["string", "null"] }, { "const": false }]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"additionalProperties": false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"additionalProperties": false
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"redirects": {
|
|
50
|
+
"description": "Declarative permanent / temporary redirects for moved URLs. Compiled once at boot by compileRedirectRules in redirects.js. A malformed entry is dropped with a warning.",
|
|
51
|
+
"type": "array",
|
|
52
|
+
"items": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"required": ["source", "destination"],
|
|
55
|
+
"properties": {
|
|
56
|
+
"source": {
|
|
57
|
+
"description": "Path pattern matched with the native URLPattern API (so :param and :rest* syntax works).",
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"destination": {
|
|
61
|
+
"description": "Target path, a path referencing named groups captured by source, or an absolute URL. The incoming query string is preserved and merged onto the destination.",
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
"permanent": {
|
|
65
|
+
"description": "true (the default) is a 308 Permanent Redirect, false is a 307 Temporary Redirect. Both preserve the request method and body. statusCode wins over this when set.",
|
|
66
|
+
"type": "boolean",
|
|
67
|
+
"default": true
|
|
68
|
+
},
|
|
69
|
+
"statusCode": {
|
|
70
|
+
"description": "Explicit redirect status, for a tool needing a legacy code. Wins over permanent. One of 301, 302, 303, 307, 308.",
|
|
71
|
+
"type": "integer",
|
|
72
|
+
"enum": [301, 302, 303, 307, 308]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"additionalProperties": false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"trailingSlash": {
|
|
79
|
+
"description": "Trailing-slash canonicalization policy. 'never' strips a trailing slash, 'always' adds one (both via a 308 redirect), 'ignore' (the default) does nothing. An unrecognized value is treated as 'ignore'. Read by readTrailingSlashPolicy in redirects.js.",
|
|
80
|
+
"type": "string",
|
|
81
|
+
"enum": ["never", "always", "ignore"],
|
|
82
|
+
"default": "ignore"
|
|
83
|
+
},
|
|
84
|
+
"basePath": {
|
|
85
|
+
"description": "Sub-path deployment prefix for an app mounted under example.com/app/ behind a proxy that does NOT strip the prefix. 'app', '/app', and '/app/' all normalize to '/app'; an empty value (the default) is a root mount and a pure no-op. The prefix is stripped from the incoming path at ingress and prepended to every framework-emitted URL (importmap targets, modulepreload hints, boot module specifiers, the dev reload src). Read by readBasePath in base-path.js. Author-written <a href> links and client-router navigation are NOT auto-prefixed (a documented follow-up).",
|
|
86
|
+
"type": "string",
|
|
87
|
+
"default": ""
|
|
88
|
+
},
|
|
89
|
+
"csp": {
|
|
90
|
+
"description": "Content-Security-Policy config. Off by default. true enables a strict nonce-based default policy. An object customizes directives and report-only mode. Read by readCspConfig in csp.js.",
|
|
91
|
+
"oneOf": [
|
|
92
|
+
{
|
|
93
|
+
"description": "true enables the strict default policy, false (or absence) disables CSP.",
|
|
94
|
+
"type": "boolean"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"description": "Custom config. directives merges over the strict defaults (a null / false / '' value drops a default directive); reportOnly emits the Content-Security-Policy-Report-Only header. A bare directive map (without a directives key) is also accepted.",
|
|
98
|
+
"type": "object",
|
|
99
|
+
"properties": {
|
|
100
|
+
"directives": {
|
|
101
|
+
"description": "Directive map merged over the strict defaults, e.g. { \"connect-src\": \"'self' https://api.example.com\" }. A __NONCE__ token in a value is replaced with the per-request nonce.",
|
|
102
|
+
"type": "object",
|
|
103
|
+
"additionalProperties": {
|
|
104
|
+
"type": ["string", "null", "boolean"]
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"reportOnly": {
|
|
108
|
+
"description": "true emits Content-Security-Policy-Report-Only instead of the enforcing header (the staged-rollout path).",
|
|
109
|
+
"type": "boolean",
|
|
110
|
+
"default": false
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
"maxBodyBytes": {
|
|
117
|
+
"description": "JSON / RPC request body cap in bytes. Default 1048576 (1 MiB). A value of 0 disables the cap. The WEBJS_MAX_BODY_BYTES env override wins. Read by readBodyLimits in body-limit.js.",
|
|
118
|
+
"type": "integer",
|
|
119
|
+
"minimum": 0,
|
|
120
|
+
"default": 1048576
|
|
121
|
+
},
|
|
122
|
+
"maxMultipartBytes": {
|
|
123
|
+
"description": "Form / multipart request body cap in bytes. Default 10485760 (10 MiB). A value of 0 disables the cap. The WEBJS_MAX_MULTIPART_BYTES env override wins. Read by readBodyLimits in body-limit.js.",
|
|
124
|
+
"type": "integer",
|
|
125
|
+
"minimum": 0,
|
|
126
|
+
"default": 10485760
|
|
127
|
+
},
|
|
128
|
+
"requestTimeoutMs": {
|
|
129
|
+
"description": "Max time in ms to receive the ENTIRE request (headers plus body). Default 30000. A value of 0 disables the timeout. The WEBJS_REQUEST_TIMEOUT_MS env override wins. Read by computeServerTimeouts in body-limit.js.",
|
|
130
|
+
"type": "integer",
|
|
131
|
+
"minimum": 0,
|
|
132
|
+
"default": 30000
|
|
133
|
+
},
|
|
134
|
+
"headersTimeoutMs": {
|
|
135
|
+
"description": "Max time in ms to receive just the request headers. Default 20000. Clamped strictly under requestTimeoutMs per node semantics. A value of 0 disables the timeout. The WEBJS_HEADERS_TIMEOUT_MS env override wins. Read by computeServerTimeouts in body-limit.js.",
|
|
136
|
+
"type": "integer",
|
|
137
|
+
"minimum": 0,
|
|
138
|
+
"default": 20000
|
|
139
|
+
},
|
|
140
|
+
"keepAliveTimeoutMs": {
|
|
141
|
+
"description": "Idle time in ms before a kept-alive socket is closed. Default 5000. A value of 0 disables the timeout. The WEBJS_KEEP_ALIVE_TIMEOUT_MS env override wins. Read by computeServerTimeouts in body-limit.js.",
|
|
142
|
+
"type": "integer",
|
|
143
|
+
"minimum": 0,
|
|
144
|
+
"default": 5000
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|