silgi 0.39.9 → 0.39.10

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.39.9";
4
+ const version = "0.39.10";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -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
- silgi.globalMiddlewares.push({
345
- middleware: routeObject.setup,
346
- method,
347
- route
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,
@@ -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("Method is required createSchema " + path);
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];
@@ -609,7 +609,7 @@ interface ResolvedMiddlewareDefinition {
609
609
  [methodAndPath: string]: {
610
610
  setup: MiddlewareSetup;
611
611
  global?: string | undefined;
612
- method: HTTPMethod | false;
612
+ method?: HTTPMethod[];
613
613
  };
614
614
  }
615
615
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.39.9",
4
+ "version": "0.39.10",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {