sprint-es 0.0.134 → 0.0.135

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/cjs/cli.cjs CHANGED
@@ -425,10 +425,29 @@ async function main() {
425
425
  case "start": {
426
426
  console.log("🚀 Starting production server...");
427
427
  const isTS = fs.existsSync(path.join(projectRoot, "sprint.config.ts"));
428
- const entryFile = isTS ? fs.existsSync(path.join(projectRoot, "dist/app.js")) ? "dist/app.js" : "dist/index.js" : fs.existsSync(path.join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
429
- if (!fs.existsSync(path.join(projectRoot, entryFile))) {
430
- console.error(`[Sprint] Entry file not found: ${entryFile}`);
431
- console.error("[Sprint] Did you run 'npm run build' first?");
428
+ let entryFile = null;
429
+ if (isTS) {
430
+ const candidates = [
431
+ "dist/app.mjs",
432
+ "dist/app.js",
433
+ "dist/index.mjs",
434
+ "dist/index.js"
435
+ ];
436
+ entryFile = candidates.find((f) => fs.existsSync(path.join(projectRoot, f))) ?? null;
437
+ } else {
438
+ const candidates = [
439
+ "src/app.js",
440
+ "src/app.mjs",
441
+ "src/index.js",
442
+ "src/index.mjs"
443
+ ];
444
+ entryFile = candidates.find((f) => fs.existsSync(path.join(projectRoot, f))) ?? null;
445
+ }
446
+ if (!entryFile) {
447
+ console.error(`[Sprint] Entry file not found.`);
448
+ console.error(
449
+ isTS ? "[Sprint] Did you run 'sprint-es build' first? Expected dist/app.mjs or dist/index.mjs" : "[Sprint] Expected src/app.js or src/index.js"
450
+ );
432
451
  process.exit(1);
433
452
  }
434
453
  await runCommand(`node "${path.join(projectRoot, entryFile)}"`, { NODE_ENV: "production" });
@@ -127,6 +127,7 @@ class Sprint {
127
127
  this.urlEncodedLimit = "50mb";
128
128
  this.prefix = "";
129
129
  this.loadedMiddlewares = [];
130
+ this.counters = { routes: 0, middlewares: 0, cronjobs: 0 };
130
131
  this.openapi = {
131
132
  generateOnBuild: false,
132
133
  path: "/openapi.json",
@@ -265,6 +266,7 @@ class Sprint {
265
266
  console.warn("[Sprint] Failed to load graphql-http or ruru:", err);
266
267
  }
267
268
  }
269
+ this.loadNotFound();
268
270
  if (finalConfig.autoListen) this.listen();
269
271
  });
270
272
  });
@@ -393,6 +395,7 @@ class Sprint {
393
395
  name,
394
396
  filePath
395
397
  });
398
+ this.counters.middlewares++;
396
399
  if (isVerbose) console.log(`[Sprint] Loaded middleware: ${name} (priority: ${config.priority ?? 100})`);
397
400
  }
398
401
  } catch (err) {
@@ -464,6 +467,7 @@ class Sprint {
464
467
  this.app.use(finalRoute, router);
465
468
  if (isVerbose) console.log(`[Sprint] Loaded route: ${finalRoute} -> ${filePath}`);
466
469
  }
470
+ this.counters.routes += router.stack.length;
467
471
  }
468
472
  } catch (err) {
469
473
  console.warn(`[Sprint] Failed to load route ${filePath}:`, err);
@@ -484,6 +488,7 @@ class Sprint {
484
488
  const moduleUrl = url.pathToFileURL(filePath).href;
485
489
  await import(moduleUrl);
486
490
  if (isVerbose) console.log(`[Sprint] Loaded cronjob: ${file.replace(/\.(ts|js)$/, "")}`);
491
+ this.counters.cronjobs++;
487
492
  } catch (err) {
488
493
  console.warn(`[Sprint] Failed to load cronjob ${filePath}:`, err);
489
494
  }
@@ -822,10 +827,7 @@ class Sprint {
822
827
  });
823
828
  };
824
829
  tryListen(basePort);
825
- this.routesLoaded.then(() => {
826
- this.loadNotFound();
827
- if (callback) callback();
828
- });
830
+ if (callback) callback();
829
831
  }
830
832
  }
831
833
  function createSchemaValidationMiddleware(schema) {
package/dist/esm/cli.js CHANGED
@@ -406,10 +406,29 @@ async function main() {
406
406
  case "start": {
407
407
  console.log("🚀 Starting production server...");
408
408
  const isTS = existsSync(join(projectRoot, "sprint.config.ts"));
409
- const entryFile = isTS ? existsSync(join(projectRoot, "dist/app.js")) ? "dist/app.js" : "dist/index.js" : existsSync(join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
410
- if (!existsSync(join(projectRoot, entryFile))) {
411
- console.error(`[Sprint] Entry file not found: ${entryFile}`);
412
- console.error("[Sprint] Did you run 'npm run build' first?");
409
+ let entryFile = null;
410
+ if (isTS) {
411
+ const candidates = [
412
+ "dist/app.mjs",
413
+ "dist/app.js",
414
+ "dist/index.mjs",
415
+ "dist/index.js"
416
+ ];
417
+ entryFile = candidates.find((f) => existsSync(join(projectRoot, f))) ?? null;
418
+ } else {
419
+ const candidates = [
420
+ "src/app.js",
421
+ "src/app.mjs",
422
+ "src/index.js",
423
+ "src/index.mjs"
424
+ ];
425
+ entryFile = candidates.find((f) => existsSync(join(projectRoot, f))) ?? null;
426
+ }
427
+ if (!entryFile) {
428
+ console.error(`[Sprint] Entry file not found.`);
429
+ console.error(
430
+ isTS ? "[Sprint] Did you run 'sprint-es build' first? Expected dist/app.mjs or dist/index.mjs" : "[Sprint] Expected src/app.js or src/index.js"
431
+ );
413
432
  process.exit(1);
414
433
  }
415
434
  await runCommand(`node "${join(projectRoot, entryFile)}"`, { NODE_ENV: "production" });
package/dist/esm/index.js CHANGED
@@ -102,6 +102,7 @@ class Sprint {
102
102
  this.urlEncodedLimit = "50mb";
103
103
  this.prefix = "";
104
104
  this.loadedMiddlewares = [];
105
+ this.counters = { routes: 0, middlewares: 0, cronjobs: 0 };
105
106
  this.openapi = {
106
107
  generateOnBuild: false,
107
108
  path: "/openapi.json",
@@ -240,6 +241,7 @@ class Sprint {
240
241
  console.warn("[Sprint] Failed to load graphql-http or ruru:", err);
241
242
  }
242
243
  }
244
+ this.loadNotFound();
243
245
  if (finalConfig.autoListen) this.listen();
244
246
  });
245
247
  });
@@ -368,6 +370,7 @@ class Sprint {
368
370
  name,
369
371
  filePath
370
372
  });
373
+ this.counters.middlewares++;
371
374
  if (isVerbose) console.log(`[Sprint] Loaded middleware: ${name} (priority: ${config.priority ?? 100})`);
372
375
  }
373
376
  } catch (err) {
@@ -439,6 +442,7 @@ class Sprint {
439
442
  this.app.use(finalRoute, router);
440
443
  if (isVerbose) console.log(`[Sprint] Loaded route: ${finalRoute} -> ${filePath}`);
441
444
  }
445
+ this.counters.routes += router.stack.length;
442
446
  }
443
447
  } catch (err) {
444
448
  console.warn(`[Sprint] Failed to load route ${filePath}:`, err);
@@ -459,6 +463,7 @@ class Sprint {
459
463
  const moduleUrl = pathToFileURL(filePath).href;
460
464
  await import(moduleUrl);
461
465
  if (isVerbose) console.log(`[Sprint] Loaded cronjob: ${file.replace(/\.(ts|js)$/, "")}`);
466
+ this.counters.cronjobs++;
462
467
  } catch (err) {
463
468
  console.warn(`[Sprint] Failed to load cronjob ${filePath}:`, err);
464
469
  }
@@ -797,10 +802,7 @@ class Sprint {
797
802
  });
798
803
  };
799
804
  tryListen(basePort);
800
- this.routesLoaded.then(() => {
801
- this.loadNotFound();
802
- if (callback) callback();
803
- });
805
+ if (callback) callback();
804
806
  }
805
807
  }
806
808
  function createSchemaValidationMiddleware(schema) {
@@ -14,6 +14,7 @@ export declare class Sprint {
14
14
  private routesLoaded;
15
15
  private server;
16
16
  private loadedMiddlewares;
17
+ private counters;
17
18
  private openapi;
18
19
  private graphql;
19
20
  private graphqlSchema;
@@ -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;AA8CnC,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,MA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,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;IAY9E,gBAAgB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAInC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;CAgE7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprint-es",
3
- "version": "0.0.134",
3
+ "version": "0.0.135",
4
4
  "description": "Sprint - Quickly API",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",