hermium 0.1.2 → 0.1.3

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.
@@ -0,0 +1,611 @@
1
+ globalThis.__nitro_main__ = import.meta.url;
2
+ import { N as NodeResponse, s as serve } from "./_libs/srvx.mjs";
3
+ import { H as HTTPError, d as defineHandler, t as toEventHandler, a as defineLazyEventHandler, b as H3Core } from "./_libs/h3.mjs";
4
+ import { d as decodePath, w as withLeadingSlash, a as withoutTrailingSlash, j as joinURL } from "./_libs/ufo.mjs";
5
+ import { promises } from "node:fs";
6
+ import { fileURLToPath } from "node:url";
7
+ import { dirname, resolve } from "node:path";
8
+ import "node:http";
9
+ import "node:stream";
10
+ import "node:stream/promises";
11
+ import "node:https";
12
+ import "node:http2";
13
+ import "./_libs/rou3.mjs";
14
+ function lazyService(loader) {
15
+ let promise, mod;
16
+ return {
17
+ fetch(req) {
18
+ if (mod) {
19
+ return mod.fetch(req);
20
+ }
21
+ if (!promise) {
22
+ promise = loader().then((_mod) => mod = _mod.default || _mod);
23
+ }
24
+ return promise.then((mod2) => mod2.fetch(req));
25
+ }
26
+ };
27
+ }
28
+ const services = {
29
+ ["ssr"]: lazyService(() => import("./_ssr/index.mjs"))
30
+ };
31
+ globalThis.__nitro_vite_envs__ = services;
32
+ const errorHandler$1 = (error, event) => {
33
+ const res = defaultHandler(error, event);
34
+ return new NodeResponse(typeof res.body === "string" ? res.body : JSON.stringify(res.body, null, 2), res);
35
+ };
36
+ function defaultHandler(error, event) {
37
+ const unhandled = error.unhandled ?? !HTTPError.isError(error);
38
+ const { status = 500, statusText = "" } = unhandled ? {} : error;
39
+ if (status === 404) {
40
+ const url = event.url || new URL(event.req.url);
41
+ const baseURL = "/";
42
+ if (/^\/[^/]/.test(baseURL) && !url.pathname.startsWith(baseURL)) {
43
+ return {
44
+ status: 302,
45
+ headers: new Headers({ location: `${baseURL}${url.pathname.slice(1)}${url.search}` })
46
+ };
47
+ }
48
+ }
49
+ const headers2 = new Headers(unhandled ? {} : error.headers);
50
+ headers2.set("content-type", "application/json; charset=utf-8");
51
+ const jsonBody = unhandled ? {
52
+ status,
53
+ unhandled: true
54
+ } : typeof error.toJSON === "function" ? error.toJSON() : {
55
+ status,
56
+ statusText,
57
+ message: error.message
58
+ };
59
+ return {
60
+ status,
61
+ statusText,
62
+ headers: headers2,
63
+ body: {
64
+ error: true,
65
+ ...jsonBody
66
+ }
67
+ };
68
+ }
69
+ const errorHandlers = [errorHandler$1];
70
+ async function errorHandler(error, event) {
71
+ for (const handler of errorHandlers) {
72
+ try {
73
+ const response = await handler(error, event, { defaultHandler });
74
+ if (response) {
75
+ return response;
76
+ }
77
+ } catch (error2) {
78
+ console.error(error2);
79
+ }
80
+ }
81
+ }
82
+ const headers = ((m) => function headersRouteRule(event) {
83
+ for (const [key2, value] of Object.entries(m.options || {})) {
84
+ event.res.headers.set(key2, value);
85
+ }
86
+ });
87
+ const assets = {
88
+ "/manifest.json": {
89
+ "type": "application/json",
90
+ "etag": '"1f2-Oqn/x1R1hBTtEjA8nFhpBeFJJNg"',
91
+ "mtime": "2026-05-15T17:19:05.086Z",
92
+ "size": 498,
93
+ "path": "../public/manifest.json"
94
+ },
95
+ "/robots.txt": {
96
+ "type": "text/plain; charset=utf-8",
97
+ "etag": '"43-BEzmj4PuhUNHX+oW9uOnPSihxtU"',
98
+ "mtime": "2026-05-15T17:19:05.086Z",
99
+ "size": 67,
100
+ "path": "../public/robots.txt"
101
+ },
102
+ "/assets/IconAlertCircle-B7TgWpbP.js": {
103
+ "type": "text/javascript; charset=utf-8",
104
+ "etag": '"f9-WiYf6a4vyN+8WZzjLq2VACzulfo"',
105
+ "mtime": "2026-05-15T17:19:03.759Z",
106
+ "size": 249,
107
+ "path": "../public/assets/IconAlertCircle-B7TgWpbP.js"
108
+ },
109
+ "/assets/IconAlertTriangle-B7IYa46Q.js": {
110
+ "type": "text/javascript; charset=utf-8",
111
+ "etag": '"161-5jxnwXbjcn/Pu9ErF1eVFq/lMnc"',
112
+ "mtime": "2026-05-15T17:19:03.760Z",
113
+ "size": 353,
114
+ "path": "../public/assets/IconAlertTriangle-B7IYa46Q.js"
115
+ },
116
+ "/assets/IconCheck-B-_pWgtP.js": {
117
+ "type": "text/javascript; charset=utf-8",
118
+ "etag": '"8a-/yspPIMl+75Cmp9UPAtfMut/l9U"',
119
+ "mtime": "2026-05-15T17:19:03.760Z",
120
+ "size": 138,
121
+ "path": "../public/assets/IconCheck-B-_pWgtP.js"
122
+ },
123
+ "/assets/IconCode-AzDguzgN.js": {
124
+ "type": "text/javascript; charset=utf-8",
125
+ "etag": '"2d7-5o9+iguYKi1/eOMMgv2YvhPyUIo"',
126
+ "mtime": "2026-05-15T17:19:03.760Z",
127
+ "size": 727,
128
+ "path": "../public/assets/IconCode-AzDguzgN.js"
129
+ },
130
+ "/assets/IconLoader2-ClSf33Yd.js": {
131
+ "type": "text/javascript; charset=utf-8",
132
+ "etag": '"97-F1GIn4F4BUBb6qE6coZUr8JEYeo"',
133
+ "mtime": "2026-05-15T17:19:03.760Z",
134
+ "size": 151,
135
+ "path": "../public/assets/IconLoader2-ClSf33Yd.js"
136
+ },
137
+ "/assets/IconPlus-BcEAWT5L.js": {
138
+ "type": "text/javascript; charset=utf-8",
139
+ "etag": '"1ab-XzSdHnme1liWz0cvNiUDGmRmp7o"',
140
+ "mtime": "2026-05-15T17:19:03.760Z",
141
+ "size": 427,
142
+ "path": "../public/assets/IconPlus-BcEAWT5L.js"
143
+ },
144
+ "/assets/IconRefresh-D4MZeezY.js": {
145
+ "type": "text/javascript; charset=utf-8",
146
+ "etag": '"ec-aA3TEQxAAzI4U5Zs916tLoNZZ/U"',
147
+ "mtime": "2026-05-15T17:19:03.760Z",
148
+ "size": 236,
149
+ "path": "../public/assets/IconRefresh-D4MZeezY.js"
150
+ },
151
+ "/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2": {
152
+ "type": "font/woff2",
153
+ "etag": '"3964-jfUkxTfHRj1cpO33jEsDk2lkrvM"',
154
+ "mtime": "2026-05-15T17:19:03.759Z",
155
+ "size": 14692,
156
+ "path": "../public/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2"
157
+ },
158
+ "/favicon.png": {
159
+ "type": "image/png",
160
+ "etag": '"51fc-nI7ucKzqH3tY+82NQSPy6oksg+o"',
161
+ "mtime": "2026-05-15T17:19:05.087Z",
162
+ "size": 20988,
163
+ "path": "../public/favicon.png"
164
+ },
165
+ "/assets/index-B-EALIKE.js": {
166
+ "type": "text/javascript; charset=utf-8",
167
+ "etag": '"25b-2XD6o3gO1LpIjKUs+2rqLb/wct8"',
168
+ "mtime": "2026-05-15T17:19:03.759Z",
169
+ "size": 603,
170
+ "path": "../public/assets/index-B-EALIKE.js"
171
+ },
172
+ "/nous-logo.png": {
173
+ "type": "image/png",
174
+ "etag": '"51fc-nI7ucKzqH3tY+82NQSPy6oksg+o"',
175
+ "mtime": "2026-05-15T17:19:05.087Z",
176
+ "size": 20988,
177
+ "path": "../public/nous-logo.png"
178
+ },
179
+ "/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2": {
180
+ "type": "font/woff2",
181
+ "etag": '"3bcc-oSFlPnDlb7fAcQTPv6sqm6NgXXU"',
182
+ "mtime": "2026-05-15T17:19:03.759Z",
183
+ "size": 15308,
184
+ "path": "../public/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2"
185
+ },
186
+ "/assets/geist-latin-wght-normal-Dm3htQBi.woff2": {
187
+ "type": "font/woff2",
188
+ "etag": '"6ef0-pZqr0k2V92t+lxQ/ogxqTIOgDGM"',
189
+ "mtime": "2026-05-15T17:19:03.759Z",
190
+ "size": 28400,
191
+ "path": "../public/assets/geist-latin-wght-normal-Dm3htQBi.woff2"
192
+ },
193
+ "/assets/index-BuznEPrX.js": {
194
+ "type": "text/javascript; charset=utf-8",
195
+ "etag": '"184e-DF4K93Zrs9epewDFrkpT/2/cDfQ"',
196
+ "mtime": "2026-05-15T17:19:03.760Z",
197
+ "size": 6222,
198
+ "path": "../public/assets/index-BuznEPrX.js"
199
+ },
200
+ "/assets/index-BP5217kc.js": {
201
+ "type": "text/javascript; charset=utf-8",
202
+ "etag": '"3ea8-Xy2/9yZ2Gb2JH3uT3sTOdRSq930"',
203
+ "mtime": "2026-05-15T17:19:03.760Z",
204
+ "size": 16040,
205
+ "path": "../public/assets/index-BP5217kc.js"
206
+ },
207
+ "/assets/index-BiFHsDt6.js": {
208
+ "type": "text/javascript; charset=utf-8",
209
+ "etag": '"244c-/oGmh4AK7etPeYzQSUOoGFMtqZk"',
210
+ "mtime": "2026-05-15T17:19:03.759Z",
211
+ "size": 9292,
212
+ "path": "../public/assets/index-BiFHsDt6.js"
213
+ },
214
+ "/favicon.ico": {
215
+ "type": "image/vnd.microsoft.icon",
216
+ "etag": '"16b86-whSNzIq4ettmTwOPeSIamFPNU70"',
217
+ "mtime": "2026-05-15T17:19:05.086Z",
218
+ "size": 93062,
219
+ "path": "../public/favicon.ico"
220
+ },
221
+ "/assets/index-CsJLc3b2.js": {
222
+ "type": "text/javascript; charset=utf-8",
223
+ "etag": '"2d07-DxW0Z8KpjzUwK6B3+bV9qiZkGZw"',
224
+ "mtime": "2026-05-15T17:19:03.759Z",
225
+ "size": 11527,
226
+ "path": "../public/assets/index-CsJLc3b2.js"
227
+ },
228
+ "/assets/index-D_8SzN4W.js": {
229
+ "type": "text/javascript; charset=utf-8",
230
+ "etag": '"1d25-B0RhJ8i4Xvb0TE6TXFuTHbQchHo"',
231
+ "mtime": "2026-05-15T17:19:03.759Z",
232
+ "size": 7461,
233
+ "path": "../public/assets/index-D_8SzN4W.js"
234
+ },
235
+ "/assets/index-DmUrSr_K.js": {
236
+ "type": "text/javascript; charset=utf-8",
237
+ "etag": '"191b-5qkIs5DjSiXfKzo4HLfL9KltzSc"',
238
+ "mtime": "2026-05-15T17:19:03.759Z",
239
+ "size": 6427,
240
+ "path": "../public/assets/index-DmUrSr_K.js"
241
+ },
242
+ "/assets/index-DEVyhUPW.js": {
243
+ "type": "text/javascript; charset=utf-8",
244
+ "etag": '"a68a-Yjzu52AZ6hj+etRHmVkI3mhkt/Y"',
245
+ "mtime": "2026-05-15T17:19:03.760Z",
246
+ "size": 42634,
247
+ "path": "../public/assets/index-DEVyhUPW.js"
248
+ },
249
+ "/assets/index-D04H-m2p.js": {
250
+ "type": "text/javascript; charset=utf-8",
251
+ "etag": '"265b4-syDEvwNj8z171QSaZjnOVKx7Jl0"',
252
+ "mtime": "2026-05-15T17:19:03.760Z",
253
+ "size": 157108,
254
+ "path": "../public/assets/index-D04H-m2p.js"
255
+ },
256
+ "/assets/index-DKYPj90W.js": {
257
+ "type": "text/javascript; charset=utf-8",
258
+ "etag": '"97ee9-e+AJZTby+ilNGvU44c0l2m9dWu0"',
259
+ "mtime": "2026-05-15T17:19:03.760Z",
260
+ "size": 622313,
261
+ "path": "../public/assets/index-DKYPj90W.js"
262
+ },
263
+ "/assets/index-xH6PhxmS.js": {
264
+ "type": "text/javascript; charset=utf-8",
265
+ "etag": '"53ee-g/v4CjzGCbexUCYf5XZUviRePbw"',
266
+ "mtime": "2026-05-15T17:19:03.759Z",
267
+ "size": 21486,
268
+ "path": "../public/assets/index-xH6PhxmS.js"
269
+ },
270
+ "/assets/input-of658hyw.js": {
271
+ "type": "text/javascript; charset=utf-8",
272
+ "etag": '"197a-PRlJ2suIKtw1VzBaHPphznHCLFU"',
273
+ "mtime": "2026-05-15T17:19:03.760Z",
274
+ "size": 6522,
275
+ "path": "../public/assets/input-of658hyw.js"
276
+ },
277
+ "/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2": {
278
+ "type": "font/woff2",
279
+ "etag": '"2be0-BP5iTzJeB8nLqYAgKpWNi5o1Zm8"',
280
+ "mtime": "2026-05-15T17:19:03.759Z",
281
+ "size": 11232,
282
+ "path": "../public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2"
283
+ },
284
+ "/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2": {
285
+ "type": "font/woff2",
286
+ "etag": '"493c-n3Oy9D6jvzfMjpClqox+Zo7ERQQ"',
287
+ "mtime": "2026-05-15T17:19:03.759Z",
288
+ "size": 18748,
289
+ "path": "../public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2"
290
+ },
291
+ "/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2": {
292
+ "type": "font/woff2",
293
+ "etag": '"6568-cF1iUGbboMFZ8TfnP5HiMgl9II0"',
294
+ "mtime": "2026-05-15T17:19:03.759Z",
295
+ "size": 25960,
296
+ "path": "../public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2"
297
+ },
298
+ "/assets/inter-greek-wght-normal-CkhJZR-_.woff2": {
299
+ "type": "font/woff2",
300
+ "etag": '"4a34-xor/hj4YNqI52zFecXnUbzQ4Xs4"',
301
+ "mtime": "2026-05-15T17:19:03.759Z",
302
+ "size": 18996,
303
+ "path": "../public/assets/inter-greek-wght-normal-CkhJZR-_.woff2"
304
+ },
305
+ "/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2": {
306
+ "type": "font/woff2",
307
+ "etag": '"280c-nBythjoDQ0+5wVAendJ6wU7Xz2M"',
308
+ "mtime": "2026-05-15T17:19:03.759Z",
309
+ "size": 10252,
310
+ "path": "../public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2"
311
+ },
312
+ "/assets/switch-CgWk9YD3.js": {
313
+ "type": "text/javascript; charset=utf-8",
314
+ "etag": '"2c1-qjRGyEj5O7EWgDHnQbdnNLXVR+U"',
315
+ "mtime": "2026-05-15T17:19:03.759Z",
316
+ "size": 705,
317
+ "path": "../public/assets/switch-CgWk9YD3.js"
318
+ },
319
+ "/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2": {
320
+ "type": "font/woff2",
321
+ "etag": '"14c4c-zz61D7IQFMB9QxHvTAOk/Vh4ibQ"',
322
+ "mtime": "2026-05-15T17:19:03.759Z",
323
+ "size": 85068,
324
+ "path": "../public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2"
325
+ },
326
+ "/assets/textarea-xdRt6_lX.js": {
327
+ "type": "text/javascript; charset=utf-8",
328
+ "etag": '"2bd-HVVz7FnLWm1kA7Iy5uh+dvfkY+o"',
329
+ "mtime": "2026-05-15T17:19:03.760Z",
330
+ "size": 701,
331
+ "path": "../public/assets/textarea-xdRt6_lX.js"
332
+ },
333
+ "/assets/inter-latin-wght-normal-Dx4kXJAl.woff2": {
334
+ "type": "font/woff2",
335
+ "etag": '"bc80-8R1ym7Ck2DUNLqPQ/AYs9u8tUpg"',
336
+ "mtime": "2026-05-15T17:19:03.759Z",
337
+ "size": 48256,
338
+ "path": "../public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2"
339
+ },
340
+ "/assets/useQuery-BtGwEPDz.js": {
341
+ "type": "text/javascript; charset=utf-8",
342
+ "etag": '"2278-kpJCK9RRQX01CuDZyDd9Nkuq7n0"',
343
+ "mtime": "2026-05-15T17:19:03.760Z",
344
+ "size": 8824,
345
+ "path": "../public/assets/useQuery-BtGwEPDz.js"
346
+ },
347
+ "/assets/syntax-highlighter-CR5pD3DZ.js": {
348
+ "type": "text/javascript; charset=utf-8",
349
+ "etag": '"13640-EYccPam/4bpfPEIHstNeRfq/EVw"',
350
+ "mtime": "2026-05-15T17:19:03.760Z",
351
+ "size": 79424,
352
+ "path": "../public/assets/syntax-highlighter-CR5pD3DZ.js"
353
+ },
354
+ "/assets/styles-C9Ypt703.css": {
355
+ "type": "text/css; charset=utf-8",
356
+ "etag": '"1ce82-H5vvbDW58zZYOuMmxTE90HCRYoI"',
357
+ "mtime": "2026-05-15T17:19:03.759Z",
358
+ "size": 118402,
359
+ "path": "../public/assets/styles-C9Ypt703.css"
360
+ }
361
+ };
362
+ function readAsset(id) {
363
+ const serverDir = dirname(fileURLToPath(globalThis.__nitro_main__));
364
+ return promises.readFile(resolve(serverDir, assets[id].path));
365
+ }
366
+ const publicAssetBases = {};
367
+ function isPublicAssetURL(id = "") {
368
+ if (assets[id]) {
369
+ return true;
370
+ }
371
+ for (const base in publicAssetBases) {
372
+ if (id.startsWith(base)) {
373
+ return true;
374
+ }
375
+ }
376
+ return false;
377
+ }
378
+ function getAsset(id) {
379
+ return assets[id];
380
+ }
381
+ const METHODS = /* @__PURE__ */ new Set(["HEAD", "GET"]);
382
+ const EncodingMap = {
383
+ gzip: ".gz",
384
+ br: ".br",
385
+ zstd: ".zst"
386
+ };
387
+ const _Blc79K = defineHandler((event) => {
388
+ if (event.req.method && !METHODS.has(event.req.method)) {
389
+ return;
390
+ }
391
+ let id = decodePath(withLeadingSlash(withoutTrailingSlash(event.url.pathname)));
392
+ let asset;
393
+ const encodingHeader = event.req.headers.get("accept-encoding") || "";
394
+ const encodings = [...encodingHeader.split(",").map((e) => EncodingMap[e.trim()]).filter(Boolean).sort(), ""];
395
+ for (const encoding of encodings) {
396
+ for (const _id of [id + encoding, joinURL(id, "index.html" + encoding)]) {
397
+ const _asset = getAsset(_id);
398
+ if (_asset) {
399
+ asset = _asset;
400
+ id = _id;
401
+ break;
402
+ }
403
+ }
404
+ }
405
+ if (!asset) {
406
+ if (isPublicAssetURL(id)) {
407
+ event.res.headers.delete("Cache-Control");
408
+ throw new HTTPError({ status: 404 });
409
+ }
410
+ return;
411
+ }
412
+ if (encodings.length > 1) {
413
+ event.res.headers.append("Vary", "Accept-Encoding");
414
+ }
415
+ const ifNotMatch = event.req.headers.get("if-none-match") === asset.etag;
416
+ if (ifNotMatch) {
417
+ event.res.status = 304;
418
+ event.res.statusText = "Not Modified";
419
+ return "";
420
+ }
421
+ const ifModifiedSinceH = event.req.headers.get("if-modified-since");
422
+ const mtimeDate = new Date(asset.mtime);
423
+ if (ifModifiedSinceH && asset.mtime && new Date(ifModifiedSinceH) >= mtimeDate) {
424
+ event.res.status = 304;
425
+ event.res.statusText = "Not Modified";
426
+ return "";
427
+ }
428
+ if (asset.type) {
429
+ event.res.headers.set("Content-Type", asset.type);
430
+ }
431
+ if (asset.etag && !event.res.headers.has("ETag")) {
432
+ event.res.headers.set("ETag", asset.etag);
433
+ }
434
+ if (asset.mtime && !event.res.headers.has("Last-Modified")) {
435
+ event.res.headers.set("Last-Modified", mtimeDate.toUTCString());
436
+ }
437
+ if (asset.encoding && !event.res.headers.has("Content-Encoding")) {
438
+ event.res.headers.set("Content-Encoding", asset.encoding);
439
+ }
440
+ if (asset.size > 0 && !event.res.headers.has("Content-Length")) {
441
+ event.res.headers.set("Content-Length", asset.size.toString());
442
+ }
443
+ return readAsset(id);
444
+ });
445
+ const findRouteRules = /* @__PURE__ */ (() => {
446
+ const $0 = [{ name: "headers", route: "/assets/**", handler: headers, options: { "cache-control": "public, max-age=31536000, immutable" } }];
447
+ return (m, p) => {
448
+ let r = [];
449
+ if (p.charCodeAt(p.length - 1) === 47) p = p.slice(0, -1) || "/";
450
+ let s = p.split("/"), l = s.length;
451
+ if (l > 1) {
452
+ if (s[1] === "assets") {
453
+ r.unshift({ data: $0, params: { "_": s.slice(2).join("/") } });
454
+ }
455
+ }
456
+ return r;
457
+ };
458
+ })();
459
+ const _lazy_e_pUQd = defineLazyEventHandler(() => import("./_chunks/ssr-renderer.mjs"));
460
+ const findRoute = /* @__PURE__ */ (() => {
461
+ const data = { route: "/**", handler: _lazy_e_pUQd };
462
+ return ((_m, p) => {
463
+ return { data, params: { "_": p.slice(1) } };
464
+ });
465
+ })();
466
+ const globalMiddleware = [
467
+ toEventHandler(_Blc79K)
468
+ ].filter(Boolean);
469
+ const APP_ID = "default";
470
+ function useNitroApp() {
471
+ let instance = useNitroApp._instance;
472
+ if (instance) {
473
+ return instance;
474
+ }
475
+ instance = useNitroApp._instance = createNitroApp();
476
+ globalThis.__nitro__ = globalThis.__nitro__ || {};
477
+ globalThis.__nitro__[APP_ID] = instance;
478
+ return instance;
479
+ }
480
+ function createNitroApp() {
481
+ const hooks = void 0;
482
+ const captureError = (error, errorCtx) => {
483
+ if (errorCtx?.event) {
484
+ const errors = errorCtx.event.req.context?.nitro?.errors;
485
+ if (errors) {
486
+ errors.push({
487
+ error,
488
+ context: errorCtx
489
+ });
490
+ }
491
+ }
492
+ };
493
+ const h3App = createH3App({ onError(error, event) {
494
+ return errorHandler(error, event);
495
+ } });
496
+ let appHandler = (req) => {
497
+ req.context ||= {};
498
+ req.context.nitro = req.context.nitro || { errors: [] };
499
+ return h3App.fetch(req);
500
+ };
501
+ const app = {
502
+ fetch: appHandler,
503
+ h3: h3App,
504
+ hooks,
505
+ captureError
506
+ };
507
+ return app;
508
+ }
509
+ function createH3App(config) {
510
+ const h3App = new H3Core(config);
511
+ h3App["~findRoute"] = (event) => findRoute(event.req.method, event.url.pathname);
512
+ h3App["~middleware"].push(...globalMiddleware);
513
+ {
514
+ h3App["~getMiddleware"] = (event, route) => {
515
+ const pathname = event.url.pathname;
516
+ const method = event.req.method;
517
+ const middleware = [];
518
+ {
519
+ const routeRules = getRouteRules(method, pathname);
520
+ event.context.routeRules = routeRules?.routeRules;
521
+ if (routeRules?.routeRuleMiddleware.length) {
522
+ middleware.push(...routeRules.routeRuleMiddleware);
523
+ }
524
+ }
525
+ middleware.push(...h3App["~middleware"]);
526
+ if (route?.data?.middleware?.length) {
527
+ middleware.push(...route.data.middleware);
528
+ }
529
+ return middleware;
530
+ };
531
+ }
532
+ return h3App;
533
+ }
534
+ function getRouteRules(method, pathname) {
535
+ const m = findRouteRules(method, pathname);
536
+ if (!m?.length) {
537
+ return { routeRuleMiddleware: [] };
538
+ }
539
+ const routeRules = {};
540
+ for (const layer of m) {
541
+ for (const rule of layer.data) {
542
+ const currentRule = routeRules[rule.name];
543
+ if (currentRule) {
544
+ if (rule.options === false) {
545
+ delete routeRules[rule.name];
546
+ continue;
547
+ }
548
+ if (typeof currentRule.options === "object" && typeof rule.options === "object") {
549
+ currentRule.options = {
550
+ ...currentRule.options,
551
+ ...rule.options
552
+ };
553
+ } else {
554
+ currentRule.options = rule.options;
555
+ }
556
+ currentRule.route = rule.route;
557
+ currentRule.params = {
558
+ ...currentRule.params,
559
+ ...layer.params
560
+ };
561
+ } else if (rule.options !== false) {
562
+ routeRules[rule.name] = {
563
+ ...rule,
564
+ params: layer.params
565
+ };
566
+ }
567
+ }
568
+ }
569
+ const middleware = [];
570
+ const orderedRules = Object.values(routeRules).sort((a, b) => (a.handler?.order || 0) - (b.handler?.order || 0));
571
+ for (const rule of orderedRules) {
572
+ if (rule.options === false || !rule.handler) {
573
+ continue;
574
+ }
575
+ middleware.push(rule.handler(rule));
576
+ }
577
+ return {
578
+ routeRules,
579
+ routeRuleMiddleware: middleware
580
+ };
581
+ }
582
+ function _captureError(error, type) {
583
+ console.error(`[${type}]`, error);
584
+ useNitroApp().captureError?.(error, { tags: [type] });
585
+ }
586
+ function trapUnhandledErrors() {
587
+ process.on("unhandledRejection", (error) => _captureError(error, "unhandledRejection"));
588
+ process.on("uncaughtException", (error) => _captureError(error, "uncaughtException"));
589
+ }
590
+ const tracingSrvxPlugins = [];
591
+ const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
592
+ const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
593
+ const host = process.env.NITRO_HOST || process.env.HOST;
594
+ const cert = process.env.NITRO_SSL_CERT;
595
+ const key = process.env.NITRO_SSL_KEY;
596
+ const nitroApp = useNitroApp();
597
+ serve({
598
+ port,
599
+ hostname: host,
600
+ tls: cert && key ? {
601
+ cert,
602
+ key
603
+ } : void 0,
604
+ fetch: nitroApp.fetch,
605
+ plugins: [...tracingSrvxPlugins]
606
+ });
607
+ trapUnhandledErrors();
608
+ const nodeServer = {};
609
+ export {
610
+ nodeServer as default
611
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermium",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Hermium CLI — self-hosted AI chat dashboard for Hermes Agent",
5
5
  "repository": {
6
6
  "type": "git",