@nuxt/nitro-server 3.20.2 → 3.21.0
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/README.md +4 -2
- package/dist/index.d.mts +279 -43
- package/dist/index.mjs +695 -733
- package/dist/runtime/handlers/{error.d.ts → error.d.mts} +1 -1
- package/dist/runtime/handlers/error.mjs +78 -0
- package/dist/runtime/handlers/island.d.mts +2 -0
- package/dist/runtime/handlers/island.mjs +123 -0
- package/dist/runtime/handlers/renderer.d.mts +2 -0
- package/dist/runtime/handlers/renderer.mjs +306 -0
- package/dist/runtime/middleware/no-ssr.d.mts +2 -0
- package/dist/runtime/middleware/no-ssr.mjs +7 -0
- package/dist/runtime/plugins/dev-server-logs.d.mts +2 -0
- package/dist/runtime/plugins/dev-server-logs.mjs +94 -0
- package/dist/runtime/templates/{error-500.d.ts → error-500.d.mts} +1 -1
- package/dist/runtime/templates/error-500.mjs +15 -0
- package/dist/runtime/utils/cache.d.mts +5 -0
- package/dist/runtime/utils/cache.mjs +20 -0
- package/dist/runtime/utils/config.d.mts +1 -0
- package/dist/runtime/utils/{dev.d.ts → dev.d.mts} +1 -1
- package/dist/runtime/utils/dev.mjs +985 -0
- package/dist/runtime/utils/error.d.mts +6 -0
- package/dist/runtime/utils/error.mjs +15 -0
- package/dist/runtime/utils/paths.mjs +19 -0
- package/dist/runtime/utils/renderer/{app.d.ts → app.d.mts} +4 -4
- package/dist/runtime/utils/renderer/app.mjs +39 -0
- package/dist/runtime/utils/renderer/build-files.d.mts +18 -0
- package/dist/runtime/utils/renderer/build-files.mjs +100 -0
- package/dist/runtime/utils/renderer/{inline-styles.d.ts → inline-styles.d.mts} +1 -1
- package/dist/runtime/utils/renderer/inline-styles.mjs +13 -0
- package/dist/runtime/utils/renderer/{islands.d.ts → islands.d.mts} +5 -5
- package/dist/runtime/utils/renderer/islands.mjs +87 -0
- package/dist/runtime/utils/renderer/payload.d.mts +24 -0
- package/dist/runtime/utils/renderer/payload.mjs +64 -0
- package/package.json +19 -17
- package/dist/index.d.ts +0 -47
- package/dist/runtime/handlers/error.js +0 -64
- package/dist/runtime/handlers/island.d.ts +0 -4
- package/dist/runtime/handlers/island.js +0 -102
- package/dist/runtime/handlers/renderer.d.ts +0 -8
- package/dist/runtime/handlers/renderer.js +0 -238
- package/dist/runtime/middleware/no-ssr.d.ts +0 -2
- package/dist/runtime/middleware/no-ssr.js +0 -7
- package/dist/runtime/plugins/dev-server-logs.d.ts +0 -3
- package/dist/runtime/plugins/dev-server-logs.js +0 -82
- package/dist/runtime/templates/error-500.js +0 -6
- package/dist/runtime/utils/cache-driver.d.ts +0 -6
- package/dist/runtime/utils/cache.d.ts +0 -8
- package/dist/runtime/utils/cache.js +0 -19
- package/dist/runtime/utils/config.d.ts +0 -1
- package/dist/runtime/utils/dev.js +0 -334
- package/dist/runtime/utils/error.d.ts +0 -6
- package/dist/runtime/utils/error.js +0 -11
- package/dist/runtime/utils/paths.js +0 -16
- package/dist/runtime/utils/renderer/app.js +0 -33
- package/dist/runtime/utils/renderer/build-files.d.ts +0 -22
- package/dist/runtime/utils/renderer/build-files.js +0 -85
- package/dist/runtime/utils/renderer/inline-styles.js +0 -13
- package/dist/runtime/utils/renderer/islands.js +0 -82
- package/dist/runtime/utils/renderer/payload.d.ts +0 -37
- package/dist/runtime/utils/renderer/payload.js +0 -67
- /package/dist/runtime/utils/{config.js → config.mjs} +0 -0
- /package/dist/runtime/utils/{paths.d.ts → paths.d.mts} +0 -0
package/README.md
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
|
|
7
7
|
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
|
|
8
8
|
<a href="https://github.com/nuxt/nuxt/blob/main/LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
|
|
9
|
+
<a href="https://nuxt.com/modules"><img src="https://img.shields.io/badge/dynamic/json?url=https://nuxt.com/api/v1/modules&query=$.stats.modules&label=Modules&style=flat&colorA=18181B&colorB=28CF8D" alt="Modules"></a>
|
|
9
10
|
<a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt" alt="Website"></a>
|
|
10
11
|
<a href="https://chat.nuxt.dev"><img src="https://img.shields.io/badge/Nuxt%20Discord-18181B?logo=discord" alt="Discord"></a>
|
|
11
12
|
<a href="https://securityscorecards.dev/"><img src="https://api.securityscorecards.dev/projects/github.com/nuxt/nuxt/badge" alt="Nuxt openssf scorecard score"></a>
|
|
13
|
+
<a href="https://deepwiki.com/nuxt/nuxt"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
|
|
12
14
|
</p>
|
|
13
15
|
|
|
14
16
|
Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.
|
|
@@ -21,14 +23,14 @@ It provides a number of features that make it easy to build fast, SEO-friendly,
|
|
|
21
23
|
- Auto imports of components, composables and utils
|
|
22
24
|
- TypeScript with zero configuration
|
|
23
25
|
- Go full-stack with our server/ directory
|
|
24
|
-
- Extensible with [
|
|
26
|
+
- Extensible with [300+ modules](https://nuxt.com/modules)
|
|
25
27
|
- Deployment to a variety of [hosting platforms](https://nuxt.com/deploy)
|
|
26
28
|
- ...[and much more](https://nuxt.com) 🚀
|
|
27
29
|
|
|
28
30
|
### Table of Contents
|
|
29
31
|
|
|
30
32
|
- 🚀 [Getting Started](#getting-started)
|
|
31
|
-
- 💻 [
|
|
33
|
+
- 💻 [Vue Development](#vue-development)
|
|
32
34
|
- 📖 [Documentation](#documentation)
|
|
33
35
|
- 🧩 [Modules](#modules)
|
|
34
36
|
- ❤️ [Contribute](#contribute)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,47 +1,283 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { LogObject } from
|
|
5
|
-
import {
|
|
6
|
-
import { RuntimeConfig } from
|
|
1
|
+
import { EventHandler, H3Event } from "h3";
|
|
2
|
+
import { Nuxt } from "@nuxt/schema";
|
|
3
|
+
import { Nitro, NitroConfig, NitroDevEventHandler, NitroEventHandler, NitroOptions, NitroRouteConfig, NitroRuntimeConfig, NitroRuntimeConfigApp } from "nitropack/types";
|
|
4
|
+
import { LogObject } from "consola";
|
|
5
|
+
import { NuxtIslandContext, NuxtIslandResponse, NuxtRenderHTMLContext } from "nuxt/app";
|
|
6
|
+
import { HookResult, RuntimeConfig, TSReference } from "nuxt/schema";
|
|
7
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
|
-
}
|
|
8
|
+
//#region src/augments.d.ts
|
|
9
|
+
declare module "nitropack" {
|
|
10
|
+
interface NitroRuntimeConfigApp {
|
|
11
|
+
buildAssetsDir: string;
|
|
12
|
+
cdnURL: string;
|
|
13
|
+
}
|
|
14
|
+
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
15
|
+
interface NitroRouteConfig {
|
|
16
|
+
ssr?: boolean;
|
|
17
|
+
noScripts?: boolean;
|
|
18
|
+
/** @deprecated Use `noScripts` instead */
|
|
19
|
+
experimentalNoScripts?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface NitroRouteRules {
|
|
22
|
+
ssr?: boolean;
|
|
23
|
+
noScripts?: boolean;
|
|
24
|
+
/** @deprecated Use `noScripts` instead */
|
|
25
|
+
experimentalNoScripts?: boolean;
|
|
26
|
+
appMiddleware?: Record<string, boolean>;
|
|
27
|
+
appLayout?: string | false;
|
|
28
|
+
}
|
|
29
|
+
interface NitroRuntimeHooks {
|
|
30
|
+
"dev:ssr-logs": (ctx: {
|
|
31
|
+
logs: LogObject[];
|
|
32
|
+
path: string;
|
|
33
|
+
}) => void | Promise<void>;
|
|
34
|
+
"render:html": (htmlContext: NuxtRenderHTMLContext, context: {
|
|
35
|
+
event: H3Event;
|
|
36
|
+
}) => void | Promise<void>;
|
|
37
|
+
"render:island": (islandResponse: NuxtIslandResponse, context: {
|
|
38
|
+
event: H3Event;
|
|
39
|
+
islandContext: NuxtIslandContext;
|
|
40
|
+
}) => void | Promise<void>;
|
|
41
|
+
}
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
declare module "nitropack/types" {
|
|
44
|
+
interface NitroRuntimeConfigApp {
|
|
45
|
+
buildAssetsDir: string;
|
|
46
|
+
cdnURL: string;
|
|
47
|
+
}
|
|
48
|
+
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
49
|
+
interface NitroRouteConfig {
|
|
50
|
+
ssr?: boolean;
|
|
51
|
+
noScripts?: boolean;
|
|
52
|
+
/** @deprecated Use `noScripts` instead */
|
|
53
|
+
experimentalNoScripts?: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface NitroRouteRules {
|
|
56
|
+
ssr?: boolean;
|
|
57
|
+
noScripts?: boolean;
|
|
58
|
+
/** @deprecated Use `noScripts` instead */
|
|
59
|
+
experimentalNoScripts?: boolean;
|
|
60
|
+
appMiddleware?: Record<string, boolean>;
|
|
61
|
+
appLayout?: string | false;
|
|
62
|
+
}
|
|
63
|
+
interface NitroRuntimeHooks {
|
|
64
|
+
"dev:ssr-logs": (ctx: {
|
|
65
|
+
logs: LogObject[];
|
|
66
|
+
path: string;
|
|
67
|
+
}) => void | Promise<void>;
|
|
68
|
+
"render:html": (htmlContext: NuxtRenderHTMLContext, context: {
|
|
69
|
+
event: H3Event;
|
|
70
|
+
}) => void | Promise<void>;
|
|
71
|
+
"render:island": (islandResponse: NuxtIslandResponse, context: {
|
|
72
|
+
event: H3Event;
|
|
73
|
+
islandContext: NuxtIslandContext;
|
|
74
|
+
}) => void | Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
declare module "@nuxt/schema" {
|
|
78
|
+
interface NuxtHooks {
|
|
79
|
+
/**
|
|
80
|
+
* Called when the dev middleware is being registered on the Nitro dev server.
|
|
81
|
+
* @param handler the Vite or Webpack event handler
|
|
82
|
+
* @returns Promise
|
|
83
|
+
*/
|
|
84
|
+
"server:devHandler": (handler: EventHandler, options: {
|
|
85
|
+
cors: (path: string) => boolean;
|
|
86
|
+
}) => HookResult;
|
|
87
|
+
/**
|
|
88
|
+
* Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
|
|
89
|
+
* @param options Objects containing `references`, `declarations`
|
|
90
|
+
* @returns Promise
|
|
91
|
+
*/
|
|
92
|
+
"nitro:prepare:types": (options: {
|
|
93
|
+
references: TSReference[];
|
|
94
|
+
declarations: string[];
|
|
95
|
+
}) => HookResult;
|
|
96
|
+
/**
|
|
97
|
+
* Called before initializing Nitro, allowing customization of Nitro's configuration.
|
|
98
|
+
* @param nitroConfig The nitro config to be extended
|
|
99
|
+
* @returns Promise
|
|
100
|
+
*/
|
|
101
|
+
"nitro:config": (nitroConfig: NitroConfig) => HookResult;
|
|
102
|
+
/**
|
|
103
|
+
* Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
|
|
104
|
+
* @param nitro The created nitro object
|
|
105
|
+
* @returns Promise
|
|
106
|
+
*/
|
|
107
|
+
"nitro:init": (nitro: Nitro) => HookResult;
|
|
108
|
+
/**
|
|
109
|
+
* Called before building the Nitro instance.
|
|
110
|
+
* @param nitro The created nitro object
|
|
111
|
+
* @returns Promise
|
|
112
|
+
*/
|
|
113
|
+
"nitro:build:before": (nitro: Nitro) => HookResult;
|
|
114
|
+
/**
|
|
115
|
+
* Called after copying public assets. Allows modifying public assets before Nitro server is built.
|
|
116
|
+
* @param nitro The created nitro object
|
|
117
|
+
* @returns Promise
|
|
118
|
+
*/
|
|
119
|
+
"nitro:build:public-assets": (nitro: Nitro) => HookResult;
|
|
120
|
+
}
|
|
121
|
+
interface ConfigSchema {
|
|
122
|
+
/**
|
|
123
|
+
* Configuration for Nitro.
|
|
124
|
+
*
|
|
125
|
+
* @see [Nitro configuration docs](https://nitro.build/config)
|
|
126
|
+
*/
|
|
127
|
+
nitro: NitroConfig;
|
|
128
|
+
/**
|
|
129
|
+
* Global route options applied to matching server routes.
|
|
130
|
+
*
|
|
131
|
+
* @experimental This is an experimental feature and API may change in the future.
|
|
132
|
+
*
|
|
133
|
+
* @see [Nitro route rules documentation](https://nitro.build/config#routerules)
|
|
134
|
+
*/
|
|
135
|
+
routeRules: NitroConfig["routeRules"];
|
|
136
|
+
/**
|
|
137
|
+
* Nitro server handlers.
|
|
138
|
+
*
|
|
139
|
+
* Each handler accepts the following options:
|
|
140
|
+
* - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of [rou3](https://github.com/h3js/rou3). - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
|
|
141
|
+
*
|
|
142
|
+
* @see [`server/` directory documentation](https://nuxt.com/docs/3.x/directory-structure/server)
|
|
143
|
+
*
|
|
144
|
+
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```js
|
|
148
|
+
* serverHandlers: [
|
|
149
|
+
* { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
|
|
150
|
+
* ]
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
serverHandlers: NitroEventHandler[];
|
|
154
|
+
/**
|
|
155
|
+
* Nitro development-only server handlers.
|
|
156
|
+
*
|
|
157
|
+
* @see [Nitro server routes documentation](https://nitro.build/guide/routing)
|
|
158
|
+
*/
|
|
159
|
+
devServerHandlers: NitroDevEventHandler[];
|
|
160
|
+
}
|
|
161
|
+
interface NuxtConfig {
|
|
162
|
+
nitro?: NitroConfig;
|
|
163
|
+
}
|
|
164
|
+
interface RuntimeConfig {
|
|
165
|
+
app: NitroRuntimeConfigApp;
|
|
166
|
+
/** Only available on the server. */
|
|
167
|
+
nitro?: NitroRuntimeConfig["nitro"];
|
|
168
|
+
}
|
|
169
|
+
interface NuxtDebugOptions {
|
|
170
|
+
/** Debug options for Nitro */
|
|
171
|
+
nitro?: NitroOptions["debug"];
|
|
172
|
+
}
|
|
173
|
+
interface NuxtPage {
|
|
174
|
+
rules?: NitroRouteConfig;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
declare module "nuxt/schema" {
|
|
178
|
+
interface NuxtHooks {
|
|
179
|
+
/**
|
|
180
|
+
* Called when the dev middleware is being registered on the Nitro dev server.
|
|
181
|
+
* @param handler the Vite or Webpack event handler
|
|
182
|
+
* @returns Promise
|
|
183
|
+
*/
|
|
184
|
+
"server:devHandler": (handler: EventHandler, options: {
|
|
185
|
+
cors: (path: string) => boolean;
|
|
186
|
+
}) => HookResult;
|
|
187
|
+
/**
|
|
188
|
+
* Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
|
|
189
|
+
* @param options Objects containing `references`, `declarations`
|
|
190
|
+
* @returns Promise
|
|
191
|
+
*/
|
|
192
|
+
"nitro:prepare:types": (options: {
|
|
193
|
+
references: TSReference[];
|
|
194
|
+
declarations: string[];
|
|
195
|
+
}) => HookResult;
|
|
196
|
+
/**
|
|
197
|
+
* Called before initializing Nitro, allowing customization of Nitro's configuration.
|
|
198
|
+
* @param nitroConfig The nitro config to be extended
|
|
199
|
+
* @returns Promise
|
|
200
|
+
*/
|
|
201
|
+
"nitro:config": (nitroConfig: NitroConfig) => HookResult;
|
|
202
|
+
/**
|
|
203
|
+
* Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
|
|
204
|
+
* @param nitro The created nitro object
|
|
205
|
+
* @returns Promise
|
|
206
|
+
*/
|
|
207
|
+
"nitro:init": (nitro: Nitro) => HookResult;
|
|
208
|
+
/**
|
|
209
|
+
* Called before building the Nitro instance.
|
|
210
|
+
* @param nitro The created nitro object
|
|
211
|
+
* @returns Promise
|
|
212
|
+
*/
|
|
213
|
+
"nitro:build:before": (nitro: Nitro) => HookResult;
|
|
214
|
+
/**
|
|
215
|
+
* Called after copying public assets. Allows modifying public assets before Nitro server is built.
|
|
216
|
+
* @param nitro The created nitro object
|
|
217
|
+
* @returns Promise
|
|
218
|
+
*/
|
|
219
|
+
"nitro:build:public-assets": (nitro: Nitro) => HookResult;
|
|
220
|
+
}
|
|
221
|
+
interface ConfigSchema {
|
|
222
|
+
/**
|
|
223
|
+
* Configuration for Nitro.
|
|
224
|
+
*
|
|
225
|
+
* @see [Nitro configuration docs](https://nitro.build/config)
|
|
226
|
+
*/
|
|
227
|
+
nitro: NitroConfig;
|
|
228
|
+
/**
|
|
229
|
+
* Global route options applied to matching server routes.
|
|
230
|
+
*
|
|
231
|
+
* @experimental This is an experimental feature and API may change in the future.
|
|
232
|
+
*
|
|
233
|
+
* @see [Nitro route rules documentation](https://nitro.build/config#routerules)
|
|
234
|
+
*/
|
|
235
|
+
routeRules: NitroConfig["routeRules"];
|
|
236
|
+
/**
|
|
237
|
+
* Nitro server handlers.
|
|
238
|
+
*
|
|
239
|
+
* Each handler accepts the following options:
|
|
240
|
+
* - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of [rou3](https://github.com/h3js/rou3). - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
|
|
241
|
+
*
|
|
242
|
+
* @see [`server/` directory documentation](https://nuxt.com/docs/3.x/directory-structure/server)
|
|
243
|
+
*
|
|
244
|
+
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```js
|
|
248
|
+
* serverHandlers: [
|
|
249
|
+
* { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
|
|
250
|
+
* ]
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
serverHandlers: NitroEventHandler[];
|
|
254
|
+
/**
|
|
255
|
+
* Nitro development-only server handlers.
|
|
256
|
+
*
|
|
257
|
+
* @see [Nitro server routes documentation](https://nitro.build/guide/routing)
|
|
258
|
+
*/
|
|
259
|
+
devServerHandlers: NitroDevEventHandler[];
|
|
260
|
+
}
|
|
261
|
+
interface NuxtConfig {
|
|
262
|
+
nitro?: NitroConfig;
|
|
263
|
+
}
|
|
264
|
+
interface RuntimeConfig {
|
|
265
|
+
app: NitroRuntimeConfigApp;
|
|
266
|
+
/** Only available on the server. */
|
|
267
|
+
nitro?: NitroRuntimeConfig["nitro"];
|
|
268
|
+
}
|
|
269
|
+
interface NuxtDebugOptions {
|
|
270
|
+
/** Debug options for Nitro */
|
|
271
|
+
nitro?: NitroOptions["debug"];
|
|
272
|
+
}
|
|
273
|
+
interface NuxtPage {
|
|
274
|
+
rules?: NitroRouteConfig;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/index.d.ts
|
|
43
279
|
declare function bundle(nuxt: Nuxt & {
|
|
44
|
-
|
|
280
|
+
_nitro?: Nitro;
|
|
45
281
|
}): Promise<void>;
|
|
46
|
-
|
|
47
|
-
export { bundle };
|
|
282
|
+
//#endregion
|
|
283
|
+
export { bundle };
|