sprint-es 0.0.61 → 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.
- package/dist/cjs/index.cjs +37 -25
- package/dist/esm/index.js +37 -25
- package/dist/types/sprint.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -161,25 +161,27 @@ class Sprint {
|
|
|
161
161
|
this.loadDefaults();
|
|
162
162
|
this.loadHealthcheck();
|
|
163
163
|
this.routesLoaded = this.init();
|
|
164
|
-
|
|
165
|
-
this.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (this.openapi.swaggerUi.enabled) {
|
|
169
|
-
import("swagger-ui-express").then((swaggerUi) => {
|
|
170
|
-
this.app.use("/swagger", swaggerUi.serve, swaggerUi.setup(void 0, {
|
|
171
|
-
swaggerUrl: "/openapi.json"
|
|
172
|
-
}));
|
|
173
|
-
}).catch(() => {
|
|
174
|
-
console.error(`[Sprint] ⚠️ swagger-ui-express is not installed. Run "npm install swagger-ui-express" to enable Swagger UI.`);
|
|
164
|
+
this.routesLoaded.then(() => {
|
|
165
|
+
if (this.openapi.generateOnBuild) {
|
|
166
|
+
this.app.get("/openapi.json", (_, res) => {
|
|
167
|
+
res.json(this.generateOpenAPISpec());
|
|
175
168
|
});
|
|
169
|
+
if (this.openapi.swaggerUi.enabled) {
|
|
170
|
+
import("swagger-ui-express").then((swaggerUi) => {
|
|
171
|
+
this.app.use("/swagger", swaggerUi.serve, swaggerUi.setup(void 0, {
|
|
172
|
+
swaggerUrl: "/openapi.json"
|
|
173
|
+
}));
|
|
174
|
+
}).catch(() => {
|
|
175
|
+
console.error(`[Sprint] ⚠️ swagger-ui-express is not installed. Run "npm install swagger-ui-express" to enable Swagger UI.`);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
176
178
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
if (finalConfig.autoListen) this.listen();
|
|
180
|
+
});
|
|
179
181
|
});
|
|
180
182
|
}
|
|
181
183
|
async init() {
|
|
182
|
-
const callerDir = process.
|
|
184
|
+
const callerDir = process.cwd();
|
|
183
185
|
try {
|
|
184
186
|
const middlewaresCandidate = path.isAbsolute(this.middlewaresPath) ? this.middlewaresPath : path.join(callerDir, this.middlewaresPath);
|
|
185
187
|
if (fs.existsSync(middlewaresCandidate) && fs.statSync(middlewaresCandidate).isDirectory()) await this.loadMiddlewares(middlewaresCandidate);
|
|
@@ -189,8 +191,11 @@ class Sprint {
|
|
|
189
191
|
}
|
|
190
192
|
try {
|
|
191
193
|
const routesCandidate = path.isAbsolute(this.routesPath) ? this.routesPath : path.join(callerDir, this.routesPath);
|
|
192
|
-
|
|
193
|
-
|
|
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.`);
|
|
194
199
|
} catch (err) {
|
|
195
200
|
console.error("[Sprint] Failed to load routes:", err);
|
|
196
201
|
}
|
|
@@ -331,17 +336,24 @@ class Sprint {
|
|
|
331
336
|
if (!layer.route) continue;
|
|
332
337
|
const route = layer.route;
|
|
333
338
|
for (const routeLayer of route.stack) {
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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
|
+
}
|
|
343
354
|
}
|
|
344
355
|
}
|
|
356
|
+
console.log(`[Sprint] Registered routes for OpenAPI:`, this.registeredRoutes);
|
|
345
357
|
}
|
|
346
358
|
const routeMiddlewares = this.getMiddlewaresForRoute(routePath);
|
|
347
359
|
if (routeMiddlewares.length > 0) {
|
package/dist/esm/index.js
CHANGED
|
@@ -136,25 +136,27 @@ class Sprint {
|
|
|
136
136
|
this.loadDefaults();
|
|
137
137
|
this.loadHealthcheck();
|
|
138
138
|
this.routesLoaded = this.init();
|
|
139
|
-
|
|
140
|
-
this.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (this.openapi.swaggerUi.enabled) {
|
|
144
|
-
import("swagger-ui-express").then((swaggerUi) => {
|
|
145
|
-
this.app.use("/swagger", swaggerUi.serve, swaggerUi.setup(void 0, {
|
|
146
|
-
swaggerUrl: "/openapi.json"
|
|
147
|
-
}));
|
|
148
|
-
}).catch(() => {
|
|
149
|
-
console.error(`[Sprint] ⚠️ swagger-ui-express is not installed. Run "npm install swagger-ui-express" to enable Swagger UI.`);
|
|
139
|
+
this.routesLoaded.then(() => {
|
|
140
|
+
if (this.openapi.generateOnBuild) {
|
|
141
|
+
this.app.get("/openapi.json", (_, res) => {
|
|
142
|
+
res.json(this.generateOpenAPISpec());
|
|
150
143
|
});
|
|
144
|
+
if (this.openapi.swaggerUi.enabled) {
|
|
145
|
+
import("swagger-ui-express").then((swaggerUi) => {
|
|
146
|
+
this.app.use("/swagger", swaggerUi.serve, swaggerUi.setup(void 0, {
|
|
147
|
+
swaggerUrl: "/openapi.json"
|
|
148
|
+
}));
|
|
149
|
+
}).catch(() => {
|
|
150
|
+
console.error(`[Sprint] ⚠️ swagger-ui-express is not installed. Run "npm install swagger-ui-express" to enable Swagger UI.`);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
151
153
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
if (finalConfig.autoListen) this.listen();
|
|
155
|
+
});
|
|
154
156
|
});
|
|
155
157
|
}
|
|
156
158
|
async init() {
|
|
157
|
-
const callerDir = process.
|
|
159
|
+
const callerDir = process.cwd();
|
|
158
160
|
try {
|
|
159
161
|
const middlewaresCandidate = path.isAbsolute(this.middlewaresPath) ? this.middlewaresPath : path.join(callerDir, this.middlewaresPath);
|
|
160
162
|
if (fs.existsSync(middlewaresCandidate) && fs.statSync(middlewaresCandidate).isDirectory()) await this.loadMiddlewares(middlewaresCandidate);
|
|
@@ -164,8 +166,11 @@ class Sprint {
|
|
|
164
166
|
}
|
|
165
167
|
try {
|
|
166
168
|
const routesCandidate = path.isAbsolute(this.routesPath) ? this.routesPath : path.join(callerDir, this.routesPath);
|
|
167
|
-
|
|
168
|
-
|
|
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.`);
|
|
169
174
|
} catch (err) {
|
|
170
175
|
console.error("[Sprint] Failed to load routes:", err);
|
|
171
176
|
}
|
|
@@ -306,17 +311,24 @@ class Sprint {
|
|
|
306
311
|
if (!layer.route) continue;
|
|
307
312
|
const route = layer.route;
|
|
308
313
|
for (const routeLayer of route.stack) {
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
|
+
}
|
|
318
329
|
}
|
|
319
330
|
}
|
|
331
|
+
console.log(`[Sprint] Registered routes for OpenAPI:`, this.registeredRoutes);
|
|
320
332
|
}
|
|
321
333
|
const routeMiddlewares = this.getMiddlewaresForRoute(routePath);
|
|
322
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,OAAO,CAUb;IACF,OAAO,CAAC,gBAAgB,CAIhB;;
|
|
1
|
+
{"version":3,"file":"sprint.d.ts","sourceRoot":"","sources":["../../src/sprint.ts"],"names":[],"mappings":"AASA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