silgi 0.37.10 → 0.37.11
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
CHANGED
package/dist/core/index.mjs
CHANGED
|
@@ -841,15 +841,15 @@ async function silgiFetch(_request, options, context) {
|
|
|
841
841
|
request = new Request(_request, options);
|
|
842
842
|
} else {
|
|
843
843
|
request = _request;
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
}
|
|
844
|
+
}
|
|
845
|
+
const silgiURL = getUrlPrefix(request.url, request.method);
|
|
846
|
+
const match = findRoute(silgiCtx.router, request.method, silgiURL.path);
|
|
847
|
+
if (!match) {
|
|
848
|
+
throw createError({
|
|
849
|
+
message: "Route not found",
|
|
850
|
+
statusCode: 404,
|
|
851
|
+
statusMessage: "Route not found"
|
|
852
|
+
});
|
|
853
853
|
}
|
|
854
854
|
const silgiEvent = new _SilgiEvent(request, context);
|
|
855
855
|
let handlerRes;
|
|
@@ -3,8 +3,6 @@ import {
|
|
|
3
3
|
getRequestWebStream
|
|
4
4
|
} from "h3";
|
|
5
5
|
import {
|
|
6
|
-
createError,
|
|
7
|
-
getUrlPrefix,
|
|
8
6
|
silgiFetch,
|
|
9
7
|
useSilgi
|
|
10
8
|
} from "silgi";
|
|
@@ -16,46 +14,15 @@ export async function addNitroApp(silgiContext = useSilgi()) {
|
|
|
16
14
|
const prefixs = silgiContext.routerPrefixs;
|
|
17
15
|
for (const prefix of prefixs) {
|
|
18
16
|
nitro.router.use(`${prefix}/**`, defineEventHandler(async (event) => {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
event.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
body: event.method.toUpperCase() === "GET" ? void 0 : getRequestWebStream(event),
|
|
26
|
-
headers: event.headers
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
if (!resolvedRoute.ok) {
|
|
30
|
-
await silgiContext.callHook("fetch:error", {
|
|
31
|
-
error: new Error(resolvedRoute.statusText),
|
|
32
|
-
url: silgiURL
|
|
33
|
-
});
|
|
34
|
-
silgiContext.captureError(
|
|
35
|
-
silgiContext,
|
|
36
|
-
createError({
|
|
37
|
-
message: resolvedRoute.statusText,
|
|
38
|
-
statusCode: resolvedRoute.status,
|
|
39
|
-
statusMessage: resolvedRoute.statusText
|
|
40
|
-
}),
|
|
41
|
-
{
|
|
42
|
-
url: silgiURL,
|
|
43
|
-
tags: ["execute"]
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
throw createError({
|
|
47
|
-
statusCode: resolvedRoute.status,
|
|
48
|
-
statusMessage: resolvedRoute.statusText
|
|
49
|
-
});
|
|
17
|
+
const resolvedRoute = await silgiFetch(
|
|
18
|
+
event.path,
|
|
19
|
+
{
|
|
20
|
+
method: event.method.toUpperCase(),
|
|
21
|
+
body: event.method.toUpperCase() === "GET" ? void 0 : getRequestWebStream(event),
|
|
22
|
+
headers: event.headers
|
|
50
23
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
throw createError({
|
|
54
|
-
statusCode: 500,
|
|
55
|
-
message: "Internal Server Error",
|
|
56
|
-
cause: err
|
|
57
|
-
});
|
|
58
|
-
}
|
|
24
|
+
);
|
|
25
|
+
return resolvedRoute;
|
|
59
26
|
}));
|
|
60
27
|
}
|
|
61
28
|
}
|
package/dist/types/index.d.mts
CHANGED
|
@@ -821,12 +821,12 @@ type ModuleHookContext = Readonly<{
|
|
|
821
821
|
url: SilgiURL;
|
|
822
822
|
input?: unknown;
|
|
823
823
|
result?: unknown;
|
|
824
|
-
route
|
|
824
|
+
route?: SilgiRoute;
|
|
825
825
|
error?: Error;
|
|
826
826
|
success?: boolean;
|
|
827
827
|
cached?: boolean;
|
|
828
828
|
}> & {
|
|
829
|
-
hookContext
|
|
829
|
+
hookContext?: {
|
|
830
830
|
earlyReturnValue: any | false;
|
|
831
831
|
};
|
|
832
832
|
};
|