silgi 0.38.10 → 0.38.12
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 +31 -2
- package/dist/index.mjs +1 -0
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { getContext, createContext } from 'unctx';
|
|
|
7
7
|
import { Buffer } from 'node:buffer';
|
|
8
8
|
import { klona } from 'klona';
|
|
9
9
|
import { createStorage as createStorage$1, builtinDrivers, prefixStorage } from 'unstorage';
|
|
10
|
+
import { isDevelopment } from 'std-env';
|
|
10
11
|
import { FastURL, FastResponse } from 'srvx';
|
|
11
12
|
export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
|
|
12
13
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
@@ -102,6 +103,10 @@ class SilgiError extends Error {
|
|
|
102
103
|
if (opts.cause && !this.cause) {
|
|
103
104
|
this.cause = opts.cause;
|
|
104
105
|
}
|
|
106
|
+
if (isDevelopment && opts.cause && opts.cause instanceof Error && opts.cause.stack && this.stack) {
|
|
107
|
+
this.stack += `
|
|
108
|
+
Caused by: ${opts.cause.stack}`;
|
|
109
|
+
}
|
|
105
110
|
}
|
|
106
111
|
toJSON() {
|
|
107
112
|
const obj = {
|
|
@@ -931,7 +936,19 @@ async function middleware(event, url) {
|
|
|
931
936
|
if (m.method && m.method !== event.req.method) {
|
|
932
937
|
return;
|
|
933
938
|
}
|
|
934
|
-
|
|
939
|
+
try {
|
|
940
|
+
await silgiContext.callHook("middleware:global:on", event, m.setup);
|
|
941
|
+
} catch (error) {
|
|
942
|
+
if (isError(error)) {
|
|
943
|
+
throw error;
|
|
944
|
+
}
|
|
945
|
+
throw createError({
|
|
946
|
+
message: "Middleware error",
|
|
947
|
+
statusCode: 500,
|
|
948
|
+
statusMessage: "Middleware error",
|
|
949
|
+
cause: error
|
|
950
|
+
});
|
|
951
|
+
}
|
|
935
952
|
return m.setup.handler(event, silgiContext);
|
|
936
953
|
});
|
|
937
954
|
}
|
|
@@ -951,7 +968,19 @@ async function middleware(event, url) {
|
|
|
951
968
|
}
|
|
952
969
|
event.context.params = match.params;
|
|
953
970
|
event.context.matchedRoute = match.data;
|
|
954
|
-
|
|
971
|
+
try {
|
|
972
|
+
await silgiContext.callHook("middleware:router:on", event, match.data.setup);
|
|
973
|
+
} catch (error) {
|
|
974
|
+
if (isError(error)) {
|
|
975
|
+
throw error;
|
|
976
|
+
}
|
|
977
|
+
throw createError({
|
|
978
|
+
message: "Middleware error",
|
|
979
|
+
statusCode: 500,
|
|
980
|
+
statusMessage: "Middleware error",
|
|
981
|
+
cause: error
|
|
982
|
+
});
|
|
983
|
+
}
|
|
955
984
|
return match.data.setup.handler(event, silgiContext);
|
|
956
985
|
});
|
|
957
986
|
}
|
package/dist/index.mjs
CHANGED