silgi 0.34.13 → 0.35.1
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/cli/index.mjs +1 -1
- package/dist/core/index.mjs +9 -37
- package/dist/presets/_all.gen.mjs +2 -0
- package/dist/presets/_types.gen.d.mts +2 -2
- package/dist/presets/hono/preset.d.mts +3 -0
- package/dist/presets/hono/preset.mjs +37 -0
- package/dist/presets/next/preset.mjs +6 -2
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.mjs
CHANGED
|
@@ -390,38 +390,6 @@ async function parseRequestInput(req) {
|
|
|
390
390
|
}
|
|
391
391
|
return await req.text();
|
|
392
392
|
}
|
|
393
|
-
function wrapBodyAndContentType(options) {
|
|
394
|
-
let { body, headers } = options;
|
|
395
|
-
const setContentType = (type) => {
|
|
396
|
-
if (!headers)
|
|
397
|
-
headers = {};
|
|
398
|
-
if (headers instanceof Headers) {
|
|
399
|
-
if (!headers.has("Content-Type"))
|
|
400
|
-
headers.set("Content-Type", type);
|
|
401
|
-
} else if (Array.isArray(headers)) {
|
|
402
|
-
if (!headers.some(([k]) => k.toLowerCase() === "content-type")) {
|
|
403
|
-
headers.push(["Content-Type", type]);
|
|
404
|
-
}
|
|
405
|
-
} else {
|
|
406
|
-
if (!("content-type" in headers)) {
|
|
407
|
-
headers["Content-Type"] = type;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
if (typeof File !== "undefined" && body instanceof File) {
|
|
412
|
-
body = new Blob([body], { type: body.type });
|
|
413
|
-
setContentType(body.type || "application/octet-stream");
|
|
414
|
-
} else if (body instanceof Blob) {
|
|
415
|
-
setContentType(body.type || "application/octet-stream");
|
|
416
|
-
} else if (body && typeof body === "object") {
|
|
417
|
-
body = new Blob([JSON.stringify(body)], { type: "application/json" });
|
|
418
|
-
setContentType("application/json");
|
|
419
|
-
} else if (typeof body === "string") {
|
|
420
|
-
body = new Blob([body], { type: "text/plain" });
|
|
421
|
-
setContentType("text/plain");
|
|
422
|
-
}
|
|
423
|
-
return { body, headers };
|
|
424
|
-
}
|
|
425
393
|
|
|
426
394
|
const plusRegex = /\+/g;
|
|
427
395
|
function parseQuery(input) {
|
|
@@ -834,12 +802,8 @@ function createSilgiCore(event) {
|
|
|
834
802
|
};
|
|
835
803
|
}
|
|
836
804
|
async function silgiFetch(_request, options, context) {
|
|
805
|
+
const silgiCtx = useSilgi();
|
|
837
806
|
let request;
|
|
838
|
-
if (options) {
|
|
839
|
-
const wrapped = wrapBodyAndContentType(options);
|
|
840
|
-
options.body = wrapped.body;
|
|
841
|
-
options.headers = wrapped.headers;
|
|
842
|
-
}
|
|
843
807
|
if (typeof _request === "string") {
|
|
844
808
|
_request = substitutePathParams(_request, options?.pathParams);
|
|
845
809
|
let url = _request;
|
|
@@ -853,6 +817,14 @@ async function silgiFetch(_request, options, context) {
|
|
|
853
817
|
request = new Request(_request, options);
|
|
854
818
|
} else {
|
|
855
819
|
request = _request;
|
|
820
|
+
const match = findRoute(silgiCtx.router, _request.method, _request.url);
|
|
821
|
+
if (!match) {
|
|
822
|
+
throw createError({
|
|
823
|
+
message: "Route not found",
|
|
824
|
+
statusCode: 404,
|
|
825
|
+
statusMessage: "Route not found"
|
|
826
|
+
});
|
|
827
|
+
}
|
|
856
828
|
}
|
|
857
829
|
const silgiEvent = new _SilgiEvent(request, context);
|
|
858
830
|
let handlerRes;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import _h3 from "./h3/preset.mjs";
|
|
2
|
+
import _hono from "./hono/preset.mjs";
|
|
2
3
|
import _next from "./next/preset.mjs";
|
|
3
4
|
import _nitro from "./nitro/preset.mjs";
|
|
4
5
|
import _npmpackage from "./npmpackage/preset.mjs";
|
|
5
6
|
import _nuxt from "./nuxt/preset.mjs";
|
|
6
7
|
const presets = [
|
|
7
8
|
..._h3,
|
|
9
|
+
..._hono,
|
|
8
10
|
..._next,
|
|
9
11
|
..._nitro,
|
|
10
12
|
..._npmpackage,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface PresetOptions {
|
|
2
2
|
}
|
|
3
3
|
export declare const presetsWithConfig: readonly [];
|
|
4
|
-
export type PresetName = "h3" | "next" | "nitro" | "npm-package" | "nuxt";
|
|
5
|
-
export type PresetNameInput = "h3" | "next" | "nitro" | "npm-package" | "nuxt";
|
|
4
|
+
export type PresetName = "h3" | "hono" | "next" | "nitro" | "npm-package" | "nuxt";
|
|
5
|
+
export type PresetNameInput = "h3" | "hono" | "next" | "nitro" | "npm-package" | "nuxt";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineSilgiPreset } from "silgi/kit";
|
|
2
|
+
const hono = defineSilgiPreset(
|
|
3
|
+
{
|
|
4
|
+
// output: {
|
|
5
|
+
// dir: '{{ rootDir }}/.output',
|
|
6
|
+
// publicDir: '{{ output.dir }}/public',
|
|
7
|
+
// },
|
|
8
|
+
serverDir: "{{ rootDir }}/src/server",
|
|
9
|
+
envOptions: {
|
|
10
|
+
prefix: "HONO_",
|
|
11
|
+
altPrefix: "SILGI_"
|
|
12
|
+
},
|
|
13
|
+
imports: {
|
|
14
|
+
dirs: [
|
|
15
|
+
"!{{ serverDir }}/runtime/**",
|
|
16
|
+
"!{{ serverDir }}/api/**",
|
|
17
|
+
"!{{ serverDir }}/routes/**",
|
|
18
|
+
"!{{ serverDir }}/modules/**",
|
|
19
|
+
"!{{ serverDir }}/assets/**",
|
|
20
|
+
"!{{ serverDir }}/public/**",
|
|
21
|
+
"!{{ silgi.serverDir }}/**"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
hooks: {
|
|
25
|
+
ready: async () => {
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
storages: []
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "hono",
|
|
32
|
+
static: true,
|
|
33
|
+
url: import.meta.url
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
const presets = [hono];
|
|
37
|
+
export default presets;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineSilgiPreset } from "silgi/kit";
|
|
1
|
+
import { addNPMPackage, defineSilgiPreset } from "silgi/kit";
|
|
2
2
|
const next = defineSilgiPreset(
|
|
3
3
|
{
|
|
4
4
|
// output: {
|
|
@@ -8,7 +8,7 @@ const next = defineSilgiPreset(
|
|
|
8
8
|
serverDir: "{{ rootDir }}/src/server",
|
|
9
9
|
envOptions: {
|
|
10
10
|
prefix: "NEXT_",
|
|
11
|
-
altPrefix: "
|
|
11
|
+
altPrefix: "SILGI_"
|
|
12
12
|
},
|
|
13
13
|
imports: {
|
|
14
14
|
dirs: [
|
|
@@ -23,6 +23,10 @@ const next = defineSilgiPreset(
|
|
|
23
23
|
},
|
|
24
24
|
hooks: {
|
|
25
25
|
ready: async () => {
|
|
26
|
+
await addNPMPackage({
|
|
27
|
+
name: "defu",
|
|
28
|
+
isDev: true
|
|
29
|
+
});
|
|
26
30
|
}
|
|
27
31
|
},
|
|
28
32
|
storages: []
|