@wervt/nuxt 0.2.5 → 0.2.7
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/dist/module.js +20 -1
- package/dist/runtime/server/boot.d.ts +10 -0
- package/dist/runtime/server/boot.js +12 -0
- package/package.json +1 -1
package/dist/module.js
CHANGED
|
@@ -18,6 +18,7 @@ var module_default = defineNuxtModule({
|
|
|
18
18
|
const resolver = createResolver(import.meta.url);
|
|
19
19
|
const nitro = nuxt.options.nitro;
|
|
20
20
|
if (!nuxt.options.dev) nitro.preset ||= "deno-server";
|
|
21
|
+
const nitroMajor = Number.parseInt(getNuxtVersion(nuxt), 10) >= 5 ? 3 : 2;
|
|
21
22
|
if (!hasNuxtModule("evlog/nuxt", nuxt)) {
|
|
22
23
|
const app = await resolveAppName(nuxt.options.rootDir, options.app);
|
|
23
24
|
const config = nuxt.options;
|
|
@@ -33,6 +34,17 @@ var module_default = defineNuxtModule({
|
|
|
33
34
|
...config.evlog
|
|
34
35
|
};
|
|
35
36
|
await installModule(evlog, void 0, nuxt);
|
|
37
|
+
if (nitroMajor >= 3) {
|
|
38
|
+
const v3 = (path) => path.replace(EVLOG_NITRO2_RE, "$1/v3/$2");
|
|
39
|
+
const serverPlugins = nuxt.options._serverPlugins;
|
|
40
|
+
for (const entry of serverPlugins ?? []) if (typeof entry.plugin === "string") entry.plugin = v3(entry.plugin);
|
|
41
|
+
nuxt.hook("nitro:config", (config) => {
|
|
42
|
+
const options = config;
|
|
43
|
+
options.plugins = options.plugins?.map(v3);
|
|
44
|
+
const handler = options.errorHandler;
|
|
45
|
+
if (handler) options.errorHandler = Array.isArray(handler) ? handler.map(v3) : v3(handler);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
36
48
|
}
|
|
37
49
|
const useContentDatabase = !nuxt.options.dev && hasNuxtModule("@nuxt/content", nuxt);
|
|
38
50
|
if (useContentDatabase) {
|
|
@@ -99,11 +111,16 @@ var module_default = defineNuxtModule({
|
|
|
99
111
|
};
|
|
100
112
|
});
|
|
101
113
|
}
|
|
114
|
+
addServerHandler({
|
|
115
|
+
route: "/_wervt/boot",
|
|
116
|
+
method: "get",
|
|
117
|
+
handler: resolver.resolve("./runtime/server/boot")
|
|
118
|
+
});
|
|
102
119
|
nitro.experimental = {
|
|
103
120
|
...nitro.experimental,
|
|
104
121
|
tasks: true
|
|
105
122
|
};
|
|
106
|
-
const nitroVersion =
|
|
123
|
+
const nitroVersion = nitroMajor >= 3 ? "nitro3" : "nitro2";
|
|
107
124
|
addServerHandler({
|
|
108
125
|
route: "/_wervt/tasks/**",
|
|
109
126
|
method: "post",
|
|
@@ -175,6 +192,8 @@ var module_default = defineNuxtModule({
|
|
|
175
192
|
]);
|
|
176
193
|
}
|
|
177
194
|
});
|
|
195
|
+
/** evlog's Nitro 2 plugin and error handler, as evlog/nuxt resolves them. */
|
|
196
|
+
const EVLOG_NITRO2_RE = /([\\/]evlog[\\/]dist[\\/]nitro)[\\/](plugin|errorHandler)(\.mjs)?$/;
|
|
178
197
|
const BUILTINS = new Set(builtinModules.filter((name) => !name.startsWith("_")));
|
|
179
198
|
/** Rewrites `from 'os'` / `import('os')` to `node:os` in the output chunks. */
|
|
180
199
|
function prefixNodeBuiltins() {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineEventHandler } from "nuxt/server";
|
|
2
|
+
//#region src/runtime/server/boot.ts
|
|
3
|
+
var boot_default = defineEventHandler((event) => {
|
|
4
|
+
event.res.headers.set("cache-control", "no-store");
|
|
5
|
+
if (event.req.headers.get("x-wervt-task") !== "1") {
|
|
6
|
+
event.res.status = 404;
|
|
7
|
+
return { error: "not found" };
|
|
8
|
+
}
|
|
9
|
+
return { ok: true };
|
|
10
|
+
});
|
|
11
|
+
//#endregion
|
|
12
|
+
export { boot_default as default };
|