sprint-es 0.0.57 → 0.0.59

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.
@@ -62,6 +62,14 @@ function matchesPatterns(patterns, routePath) {
62
62
  function stripRouteGroups(routePath) {
63
63
  return routePath.split("/").filter((segment) => !/^\(.+\)$/.test(segment)).join("/") || "/";
64
64
  }
65
+ function deepMerge(target, source) {
66
+ const output = { ...target };
67
+ for (const key in source) {
68
+ if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) output[key] = deepMerge(output[key] ?? {}, source[key]);
69
+ else output[key] = source[key];
70
+ }
71
+ return output;
72
+ }
65
73
  const nodeEnv = process.env.NODE_ENV?.toLowerCase();
66
74
  const isDev = nodeEnv === "development";
67
75
  const isProd = nodeEnv === "production";
@@ -83,7 +91,7 @@ async function findProjectRoot(startDir) {
83
91
  return null;
84
92
  }
85
93
  async function loadSprintConfig() {
86
- const callerDir = process.argv[1] ? path.dirname(process.argv[1]) : process.cwd();
94
+ const callerDir = process.cwd();
87
95
  const projectRoot = await findProjectRoot(callerDir);
88
96
  if (!projectRoot) return null;
89
97
  const configFiles = ["sprint.config.ts", "sprint.config.js"];
@@ -136,7 +144,7 @@ class Sprint {
136
144
  }
137
145
  }
138
146
  };
139
- const finalConfig = { ...defaults, ...config };
147
+ const finalConfig = deepMerge(defaults, config || {});
140
148
  this.port = finalConfig.port;
141
149
  this.routesPath = finalConfig.routesPath || "./routes";
142
150
  this.middlewaresPath = finalConfig.middlewaresPath || "./middlewares";
@@ -474,7 +482,7 @@ class Sprint {
474
482
  console.log(` ${dim}Prefix:${reset} ${bold}${prefixInfo}${reset}`);
475
483
  console.log(` ${dim}Healthcheck:${reset} http://localhost:${port}${this.prefix}/healthcheck`);
476
484
  if (this.openapi.generateOnBuild) console.log(` ${dim}OpenAPI Spec:${reset} http://localhost:${port}${this.prefix}/openapi.json`);
477
- if (this.openapi.generateOnBuild) console.log(` ${dim}Swagger UI:${reset} http://localhost:${port}${this.prefix}/swagger`);
485
+ if (this.openapi.swaggerUi.enabled) console.log(` ${dim}Swagger UI:${reset} http://localhost:${port}${this.prefix}/swagger`);
478
486
  console.log("");
479
487
  console.log(` ${dim}Tip: Need stronger route protection? Learn more at${reset}`);
480
488
  console.log(` ${dim}https://docs.tpeoficial.com/docs/dymo-api/private/request-verifier${reset}`);
package/dist/esm/index.js CHANGED
@@ -37,6 +37,14 @@ function matchesPatterns(patterns, routePath) {
37
37
  function stripRouteGroups(routePath) {
38
38
  return routePath.split("/").filter((segment) => !/^\(.+\)$/.test(segment)).join("/") || "/";
39
39
  }
40
+ function deepMerge(target, source) {
41
+ const output = { ...target };
42
+ for (const key in source) {
43
+ if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) output[key] = deepMerge(output[key] ?? {}, source[key]);
44
+ else output[key] = source[key];
45
+ }
46
+ return output;
47
+ }
40
48
  const nodeEnv = process.env.NODE_ENV?.toLowerCase();
41
49
  const isDev = nodeEnv === "development";
42
50
  const isProd = nodeEnv === "production";
@@ -58,7 +66,7 @@ async function findProjectRoot(startDir) {
58
66
  return null;
59
67
  }
60
68
  async function loadSprintConfig() {
61
- const callerDir = process.argv[1] ? path.dirname(process.argv[1]) : process.cwd();
69
+ const callerDir = process.cwd();
62
70
  const projectRoot = await findProjectRoot(callerDir);
63
71
  if (!projectRoot) return null;
64
72
  const configFiles = ["sprint.config.ts", "sprint.config.js"];
@@ -111,7 +119,7 @@ class Sprint {
111
119
  }
112
120
  }
113
121
  };
114
- const finalConfig = { ...defaults, ...config };
122
+ const finalConfig = deepMerge(defaults, config || {});
115
123
  this.port = finalConfig.port;
116
124
  this.routesPath = finalConfig.routesPath || "./routes";
117
125
  this.middlewaresPath = finalConfig.middlewaresPath || "./middlewares";
@@ -449,7 +457,7 @@ class Sprint {
449
457
  console.log(` ${dim}Prefix:${reset} ${bold}${prefixInfo}${reset}`);
450
458
  console.log(` ${dim}Healthcheck:${reset} http://localhost:${port}${this.prefix}/healthcheck`);
451
459
  if (this.openapi.generateOnBuild) console.log(` ${dim}OpenAPI Spec:${reset} http://localhost:${port}${this.prefix}/openapi.json`);
452
- if (this.openapi.generateOnBuild) console.log(` ${dim}Swagger UI:${reset} http://localhost:${port}${this.prefix}/swagger`);
460
+ if (this.openapi.swaggerUi.enabled) console.log(` ${dim}Swagger UI:${reset} http://localhost:${port}${this.prefix}/swagger`);
453
461
  console.log("");
454
462
  console.log(` ${dim}Tip: Need stronger route protection? Learn more at${reset}`);
455
463
  console.log(` ${dim}https://docs.tpeoficial.com/docs/dymo-api/private/request-verifier${reset}`);
@@ -19,4 +19,5 @@ export declare function matchesPatterns(patterns: string[], routePath: string):
19
19
  * Example: "(group)/(subgroup)/api/users" -> "/api/users"
20
20
  */
21
21
  export declare function stripRouteGroups(routePath: string): string;
22
+ export declare function deepMerge<T>(target: T, source: Partial<T>): T;
22
23
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,SAAiC,CAAC;AACpD,eAAO,MAAM,SAAS,SAAqC,CAAC;AAE5D,QAAA,IAAI,UAAU,EAAE,MAAM,CAAC;AACvB,QAAA,IAAI,SAAS,EAAE,MAAM,CAAC;AAYtB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AAEjC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAoBxE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAK1D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,SAAiC,CAAC;AACpD,eAAO,MAAM,SAAS,SAAqC,CAAC;AAE5D,QAAA,IAAI,UAAU,EAAE,MAAM,CAAC;AACvB,QAAA,IAAI,SAAS,EAAE,MAAM,CAAC;AAYtB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AAEjC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAoBxE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAK1D;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAS7D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprint-es",
3
- "version": "0.0.57",
3
+ "version": "0.0.59",
4
4
  "description": "Sprint - Quickly API",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",