silgi 0.39.9 → 0.39.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 +1 -1
- package/dist/core/index.mjs +19 -10
- package/dist/types/index.d.mts +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.mjs
CHANGED
|
@@ -298,7 +298,7 @@ async function createSilgi(config) {
|
|
|
298
298
|
silgi.router = createRouter();
|
|
299
299
|
}
|
|
300
300
|
for (const routeKey in silgi.services) {
|
|
301
|
-
let method = "
|
|
301
|
+
let method = "GLOBAL";
|
|
302
302
|
let route = routeKey;
|
|
303
303
|
if (routeKey.includes(":")) {
|
|
304
304
|
const [methodPart, ...routeParts2] = routeKey.split(":");
|
|
@@ -332,7 +332,6 @@ async function createSilgi(config) {
|
|
|
332
332
|
}
|
|
333
333
|
for (const routeKey in silgi.middlewares) {
|
|
334
334
|
const routeObject = silgi.middlewares[routeKey];
|
|
335
|
-
const global = routeObject.global ?? false;
|
|
336
335
|
let method = "ALL";
|
|
337
336
|
let route = routeKey;
|
|
338
337
|
if (routeKey.includes(":")) {
|
|
@@ -340,12 +339,22 @@ async function createSilgi(config) {
|
|
|
340
339
|
method = methodPart.toUpperCase();
|
|
341
340
|
route = routeParts.join(":");
|
|
342
341
|
}
|
|
343
|
-
if (global) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
342
|
+
if (routeObject.global) {
|
|
343
|
+
if (routeObject.method) {
|
|
344
|
+
for (const method2 of routeObject.method) {
|
|
345
|
+
silgi.globalMiddlewares.push({
|
|
346
|
+
middleware: routeObject.setup,
|
|
347
|
+
method: method2,
|
|
348
|
+
route
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
silgi.globalMiddlewares.push({
|
|
353
|
+
middleware: routeObject.setup,
|
|
354
|
+
method,
|
|
355
|
+
route
|
|
356
|
+
});
|
|
357
|
+
}
|
|
349
358
|
} else {
|
|
350
359
|
addRoute(silgi._middlewareRouter, method, route, {
|
|
351
360
|
middleware: routeObject.setup,
|
|
@@ -930,7 +939,7 @@ async function middleware(event, url) {
|
|
|
930
939
|
if (_previous !== void 0 && _previous !== kNotFound) {
|
|
931
940
|
return _previous;
|
|
932
941
|
}
|
|
933
|
-
if (m.method && m.method !== event.req.method || !m.middleware) {
|
|
942
|
+
if (m.method && m.method !== "GLOBAL" && m.method !== event.req.method || !m.middleware) {
|
|
934
943
|
return;
|
|
935
944
|
}
|
|
936
945
|
try {
|
|
@@ -1031,7 +1040,7 @@ function createSchema(params) {
|
|
|
1031
1040
|
const { path, method, setup } = params;
|
|
1032
1041
|
const result = {};
|
|
1033
1042
|
if (!method) {
|
|
1034
|
-
throw new Error(
|
|
1043
|
+
throw new Error(`Method is required createSchema ${path}`);
|
|
1035
1044
|
}
|
|
1036
1045
|
for (let i = 0; i < method.length; i++) {
|
|
1037
1046
|
const methodName = method[i];
|
package/dist/types/index.d.mts
CHANGED