sprint-es 0.0.62 → 0.0.63

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.
@@ -181,7 +181,7 @@ class Sprint {
181
181
  });
182
182
  }
183
183
  async init() {
184
- const callerDir = process.argv[1] ? path.dirname(process.argv[1]) : process.cwd();
184
+ const callerDir = process.cwd();
185
185
  try {
186
186
  const middlewaresCandidate = path.isAbsolute(this.middlewaresPath) ? this.middlewaresPath : path.join(callerDir, this.middlewaresPath);
187
187
  if (fs.existsSync(middlewaresCandidate) && fs.statSync(middlewaresCandidate).isDirectory()) await this.loadMiddlewares(middlewaresCandidate);
@@ -191,8 +191,11 @@ class Sprint {
191
191
  }
192
192
  try {
193
193
  const routesCandidate = path.isAbsolute(this.routesPath) ? this.routesPath : path.join(callerDir, this.routesPath);
194
- if (fs.existsSync(routesCandidate) && fs.statSync(routesCandidate).isDirectory()) await this.loadRoutes(routesCandidate);
195
- else console.log(`[Sprint] Routes folder not found at: ${routesCandidate}, skipping route loading.`);
194
+ console.log(`[Sprint] Looking for routes at: ${routesCandidate}`);
195
+ if (fs.existsSync(routesCandidate) && fs.statSync(routesCandidate).isDirectory()) {
196
+ console.log(`[Sprint] Routes directory found, loading...`);
197
+ await this.loadRoutes(routesCandidate);
198
+ } else console.log(`[Sprint] Routes folder not found at: ${routesCandidate}, skipping route loading.`);
196
199
  } catch (err) {
197
200
  console.error("[Sprint] Failed to load routes:", err);
198
201
  }
@@ -333,17 +336,24 @@ class Sprint {
333
336
  if (!layer.route) continue;
334
337
  const route = layer.route;
335
338
  for (const routeLayer of route.stack) {
336
- const schema = routeLayer.handle.__sprintRouteSchema;
337
- if (!schema) continue;
338
- const method = (routeLayer.method || "").toUpperCase();
339
- if (!method) continue;
340
- this.registeredRoutes.push({
341
- method,
342
- path: finalRoute + route.path,
343
- schema
344
- });
339
+ const handlers = Array.isArray(routeLayer.handle) ? routeLayer.handle : [routeLayer.handle];
340
+ for (const handler of handlers) {
341
+ const schema = handler.__sprintRouteSchema;
342
+ if (schema) {
343
+ const method = (routeLayer.method || "").toUpperCase();
344
+ if (method) {
345
+ this.registeredRoutes.push({
346
+ method,
347
+ path: finalRoute + route.path,
348
+ schema
349
+ });
350
+ }
351
+ break;
352
+ }
353
+ }
345
354
  }
346
355
  }
356
+ console.log(`[Sprint] Registered routes for OpenAPI:`, this.registeredRoutes);
347
357
  }
348
358
  const routeMiddlewares = this.getMiddlewaresForRoute(routePath);
349
359
  if (routeMiddlewares.length > 0) {
package/dist/esm/index.js CHANGED
@@ -156,7 +156,7 @@ class Sprint {
156
156
  });
157
157
  }
158
158
  async init() {
159
- const callerDir = process.argv[1] ? path.dirname(process.argv[1]) : process.cwd();
159
+ const callerDir = process.cwd();
160
160
  try {
161
161
  const middlewaresCandidate = path.isAbsolute(this.middlewaresPath) ? this.middlewaresPath : path.join(callerDir, this.middlewaresPath);
162
162
  if (fs.existsSync(middlewaresCandidate) && fs.statSync(middlewaresCandidate).isDirectory()) await this.loadMiddlewares(middlewaresCandidate);
@@ -166,8 +166,11 @@ class Sprint {
166
166
  }
167
167
  try {
168
168
  const routesCandidate = path.isAbsolute(this.routesPath) ? this.routesPath : path.join(callerDir, this.routesPath);
169
- if (fs.existsSync(routesCandidate) && fs.statSync(routesCandidate).isDirectory()) await this.loadRoutes(routesCandidate);
170
- else console.log(`[Sprint] Routes folder not found at: ${routesCandidate}, skipping route loading.`);
169
+ console.log(`[Sprint] Looking for routes at: ${routesCandidate}`);
170
+ if (fs.existsSync(routesCandidate) && fs.statSync(routesCandidate).isDirectory()) {
171
+ console.log(`[Sprint] Routes directory found, loading...`);
172
+ await this.loadRoutes(routesCandidate);
173
+ } else console.log(`[Sprint] Routes folder not found at: ${routesCandidate}, skipping route loading.`);
171
174
  } catch (err) {
172
175
  console.error("[Sprint] Failed to load routes:", err);
173
176
  }
@@ -308,17 +311,24 @@ class Sprint {
308
311
  if (!layer.route) continue;
309
312
  const route = layer.route;
310
313
  for (const routeLayer of route.stack) {
311
- const schema = routeLayer.handle.__sprintRouteSchema;
312
- if (!schema) continue;
313
- const method = (routeLayer.method || "").toUpperCase();
314
- if (!method) continue;
315
- this.registeredRoutes.push({
316
- method,
317
- path: finalRoute + route.path,
318
- schema
319
- });
314
+ const handlers = Array.isArray(routeLayer.handle) ? routeLayer.handle : [routeLayer.handle];
315
+ for (const handler of handlers) {
316
+ const schema = handler.__sprintRouteSchema;
317
+ if (schema) {
318
+ const method = (routeLayer.method || "").toUpperCase();
319
+ if (method) {
320
+ this.registeredRoutes.push({
321
+ method,
322
+ path: finalRoute + route.path,
323
+ schema
324
+ });
325
+ }
326
+ break;
327
+ }
328
+ }
320
329
  }
321
330
  }
331
+ console.log(`[Sprint] Registered routes for OpenAPI:`, this.registeredRoutes);
322
332
  }
323
333
  const routeMiddlewares = this.getMiddlewaresForRoute(routePath);
324
334
  if (routeMiddlewares.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"sprint.d.ts","sourceRoot":"","sources":["../../src/sprint.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAA+B,gBAAgB,EAAoB,MAAM,SAAS,CAAC;AACnG,OAAO,OAAO,EAAE,EAAE,WAAW,EAAoD,MAAM,SAAS,CAAC;AAejG,eAAO,MAAM,aAAa,SAAQ,CAAC;AACnC,eAAO,MAAM,YAAY,SAAS,CAAC;AAwCnC,qBAAa,MAAM;IACR,GAAG,EAAE,WAAW,CAAC;IACxB,OAAO,CAAC,IAAI,CAAwD;IACpE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC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AC,SAAS,CAAkB;IACnC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC,OAAO,CAUb;IACF,OAAO,CAAC,gBAAgB,CAIhB;;YAoEM,IAAI;IAkClB,OAAO,CAAC,YAAY;IAiDpB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA4B9B;;OAEG;YACW,eAAe;IAgC7B,OAAO,CAAC,eAAe;YAcT,UAAU;YAoFV,YAAY;IAmB1B,OAAO,CAAC,YAAY;IAgCpB,+BAA+B;IAC/B,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,mBAAmB;IA6BpB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAClC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACnC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAClC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACrC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACpC,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,gBAAgB,EAAE,YAAY,CAAC,EAAE,OAAO;IAYlF,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;CA0DzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprint-es",
3
- "version": "0.0.62",
3
+ "version": "0.0.63",
4
4
  "description": "Sprint - Quickly API",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",