sprint-es 0.0.74 → 0.0.76
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 +197 -3
- package/dist/cjs/modules/schemas/index.cjs +52 -0
- package/dist/esm/index.js +197 -3
- package/dist/esm/modules/schemas/index.js +54 -1
- package/dist/types/middleware.d.ts.map +1 -1
- package/dist/types/modules/schemas/index.d.ts +12 -0
- package/dist/types/modules/schemas/index.d.ts.map +1 -1
- package/dist/types/modules/schemas/types.d.ts +4 -0
- package/dist/types/modules/schemas/types.d.ts.map +1 -1
- package/dist/types/sprint.d.ts +1 -0
- package/dist/types/sprint.d.ts.map +1 -1
- package/dist/types/types.d.ts +16 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -439,6 +439,7 @@ class Sprint {
|
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
};
|
|
442
|
+
let allParams = [];
|
|
442
443
|
if (route.schema?.body && !["GET", "HEAD", "DELETE"].includes(route.method)) {
|
|
443
444
|
try {
|
|
444
445
|
const bodySchema = this.zodSchemaToOpenAPI(route.schema.body);
|
|
@@ -458,11 +459,81 @@ class Sprint {
|
|
|
458
459
|
if (route.schema?.queryParams) {
|
|
459
460
|
try {
|
|
460
461
|
const params = this.zodParamsToOpenAPI(route.schema.queryParams);
|
|
461
|
-
if (params.length > 0)
|
|
462
|
+
if (params.length > 0) allParams.push(...params);
|
|
462
463
|
} catch (e) {
|
|
463
464
|
console.warn("[Sprint] Failed to convert query params schema:", e);
|
|
464
465
|
}
|
|
465
466
|
}
|
|
467
|
+
if (route.schema?.headers) {
|
|
468
|
+
try {
|
|
469
|
+
const headers = this.zodHeadersToOpenAPI(route.schema.headers);
|
|
470
|
+
if (headers.length > 0) allParams.push(...headers);
|
|
471
|
+
} catch (e) {
|
|
472
|
+
console.warn("[Sprint] Failed to convert headers schema:", e);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
if (this.openapi.generateOnBuild) {
|
|
476
|
+
try {
|
|
477
|
+
const routeMiddlewares = this.getMiddlewaresForRoute(route.path);
|
|
478
|
+
for (const mw of this.loadedMiddlewares) {
|
|
479
|
+
const includePatterns = Array.isArray(mw.include) ? mw.include : [mw.include || "/**"];
|
|
480
|
+
const excludePatterns = Array.isArray(mw.exclude) ? mw.exclude : mw.exclude ? [mw.exclude] : [];
|
|
481
|
+
const isIncluded = matchesPatterns(includePatterns, route.path);
|
|
482
|
+
const isExcluded = excludePatterns.length > 0 && matchesPatterns(excludePatterns, route.path);
|
|
483
|
+
if (isIncluded && !isExcluded && mw.__sprintMiddlewareSchema) {
|
|
484
|
+
const mwSchema = mw.__sprintMiddlewareSchema;
|
|
485
|
+
if (mwSchema.queryParams) {
|
|
486
|
+
const params = this.zodParamsToOpenAPI(mwSchema.queryParams);
|
|
487
|
+
if (params.length > 0) allParams.push(...params);
|
|
488
|
+
}
|
|
489
|
+
if (mwSchema.headers) {
|
|
490
|
+
const headers = this.zodHeadersToOpenAPI(mwSchema.headers);
|
|
491
|
+
if (headers.length > 0) allParams.push(...headers);
|
|
492
|
+
}
|
|
493
|
+
if (mwSchema.sprint?.authorization) {
|
|
494
|
+
const authSchema = mwSchema.sprint.authorization;
|
|
495
|
+
const description = authSchema._def?.description;
|
|
496
|
+
let sources = ["query:token", "headers:authorization"];
|
|
497
|
+
if (description) {
|
|
498
|
+
try {
|
|
499
|
+
const parsed = JSON.parse(description);
|
|
500
|
+
if (parsed.__sprintAuthorization && parsed.sources) {
|
|
501
|
+
sources = Array.isArray(parsed.sources) ? parsed.sources : [parsed.sources];
|
|
502
|
+
}
|
|
503
|
+
} catch {
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
for (const source of sources) {
|
|
507
|
+
const [type, key] = source.split(":");
|
|
508
|
+
if (type === "query") {
|
|
509
|
+
allParams.push({
|
|
510
|
+
name: key,
|
|
511
|
+
in: "query",
|
|
512
|
+
required: true,
|
|
513
|
+
schema: { type: "string" }
|
|
514
|
+
});
|
|
515
|
+
} else if (type === "headers") {
|
|
516
|
+
allParams.push({
|
|
517
|
+
name: key,
|
|
518
|
+
in: "header",
|
|
519
|
+
required: true,
|
|
520
|
+
schema: { type: "string" }
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
} catch (e) {
|
|
528
|
+
console.warn("[Sprint] Failed to add middleware schemas to OpenAPI:", e);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
if (allParams.length > 0) {
|
|
532
|
+
const uniqueParams = allParams.filter(
|
|
533
|
+
(param, index, self) => index === self.findIndex((p) => p.name === param.name && p.in === param.in)
|
|
534
|
+
);
|
|
535
|
+
routeSpec.parameters = uniqueParams;
|
|
536
|
+
}
|
|
466
537
|
paths[route.path][method] = routeSpec;
|
|
467
538
|
}
|
|
468
539
|
return {
|
|
@@ -536,6 +607,33 @@ class Sprint {
|
|
|
536
607
|
}
|
|
537
608
|
return params;
|
|
538
609
|
}
|
|
610
|
+
zodHeadersToOpenAPI(schema) {
|
|
611
|
+
if (!schema) return [];
|
|
612
|
+
const headers = [];
|
|
613
|
+
const shape = schema.shape || schema._def?.shape();
|
|
614
|
+
if (!shape) return [];
|
|
615
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
616
|
+
const zodDef = value._def;
|
|
617
|
+
const typeName = zodDef?.typeName;
|
|
618
|
+
let paramSchema = {};
|
|
619
|
+
if (typeName === "ZodString") {
|
|
620
|
+
paramSchema = { type: "string" };
|
|
621
|
+
} else if (typeName === "ZodNumber") {
|
|
622
|
+
paramSchema = { type: "number" };
|
|
623
|
+
} else if (typeName === "ZodBoolean") {
|
|
624
|
+
paramSchema = { type: "boolean" };
|
|
625
|
+
} else {
|
|
626
|
+
paramSchema = { type: "string" };
|
|
627
|
+
}
|
|
628
|
+
headers.push({
|
|
629
|
+
name: key,
|
|
630
|
+
in: "header",
|
|
631
|
+
required: !zodDef?.isOptional,
|
|
632
|
+
schema: paramSchema
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
return headers;
|
|
636
|
+
}
|
|
539
637
|
// HTTP Methods (prefix is applied automatically).
|
|
540
638
|
get(path2, handler) {
|
|
541
639
|
return this.app.get(this.applyPrefix(path2), handler);
|
|
@@ -612,6 +710,88 @@ class Sprint {
|
|
|
612
710
|
});
|
|
613
711
|
}
|
|
614
712
|
}
|
|
713
|
+
function createSchemaValidationMiddleware(schema) {
|
|
714
|
+
return (req, res, next) => {
|
|
715
|
+
const errors = [];
|
|
716
|
+
if (schema.body) {
|
|
717
|
+
const result = schema.body.safeParse(req.body);
|
|
718
|
+
if (!result.success) {
|
|
719
|
+
errors.push(...result.error.issues.map((issue) => ({
|
|
720
|
+
location: "body",
|
|
721
|
+
path: issue.path.join("."),
|
|
722
|
+
message: issue.message
|
|
723
|
+
})));
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
if (schema.queryParams) {
|
|
727
|
+
const result = schema.queryParams.safeParse(req.query);
|
|
728
|
+
if (!result.success) {
|
|
729
|
+
errors.push(...result.error.issues.map((issue) => ({
|
|
730
|
+
location: "queryParams",
|
|
731
|
+
path: issue.path.join("."),
|
|
732
|
+
message: issue.message
|
|
733
|
+
})));
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (schema.params) {
|
|
737
|
+
const result = schema.params.safeParse(req.params);
|
|
738
|
+
if (!result.success) {
|
|
739
|
+
errors.push(...result.error.issues.map((issue) => ({
|
|
740
|
+
location: "params",
|
|
741
|
+
path: issue.path.join("."),
|
|
742
|
+
message: issue.message
|
|
743
|
+
})));
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
if (schema.headers) {
|
|
747
|
+
const result = schema.headers.safeParse(req.headers);
|
|
748
|
+
if (!result.success) {
|
|
749
|
+
errors.push(...result.error.issues.map((issue) => ({
|
|
750
|
+
location: "headers",
|
|
751
|
+
path: issue.path.join("."),
|
|
752
|
+
message: issue.message
|
|
753
|
+
})));
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
if (schema.sprint?.authorization) {
|
|
757
|
+
const authSchema = schema.sprint.authorization;
|
|
758
|
+
const description = authSchema._def?.description;
|
|
759
|
+
let sources = ["query:token", "headers:authorization"];
|
|
760
|
+
if (description) {
|
|
761
|
+
try {
|
|
762
|
+
const parsed = JSON.parse(description);
|
|
763
|
+
if (parsed.__sprintAuthorization && parsed.sources) sources = Array.isArray(parsed.sources) ? parsed.sources : [parsed.sources];
|
|
764
|
+
} catch {
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
let authValue;
|
|
768
|
+
for (const source of sources) {
|
|
769
|
+
const [type, key] = source.split(":");
|
|
770
|
+
if (type === "query") {
|
|
771
|
+
const value = req.query[key];
|
|
772
|
+
if (typeof value === "string" && value.length > 0) {
|
|
773
|
+
authValue = value;
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
} else if (type === "headers") {
|
|
777
|
+
const value = req.headers[key.toLowerCase()];
|
|
778
|
+
if (typeof value === "string" && value.length > 0) {
|
|
779
|
+
authValue = value;
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
if (Array.isArray(value) && value.length > 0 && typeof value[0] === "string" && value[0].length > 0) {
|
|
783
|
+
authValue = value[0];
|
|
784
|
+
break;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
if (!authValue) errors.push({ location: "sprint.authorization", path: "authorization", message: "Authorization header or query parameter not found" });
|
|
789
|
+
else req.sprint.authorization = authValue;
|
|
790
|
+
}
|
|
791
|
+
if (errors.length > 0) return res.status(400).json({ error: "Validation failed", details: errors });
|
|
792
|
+
next();
|
|
793
|
+
};
|
|
794
|
+
}
|
|
615
795
|
function defineMiddleware(config) {
|
|
616
796
|
const wrapHandler = (handler) => {
|
|
617
797
|
return (req, res, next) => {
|
|
@@ -619,10 +799,24 @@ function defineMiddleware(config) {
|
|
|
619
799
|
if (result instanceof Promise) result.catch(next);
|
|
620
800
|
};
|
|
621
801
|
};
|
|
622
|
-
|
|
802
|
+
const handlers = [];
|
|
803
|
+
if (config.schema) {
|
|
804
|
+
handlers.push(createSchemaValidationMiddleware(config.schema));
|
|
805
|
+
}
|
|
806
|
+
const originalHandler = config.handler;
|
|
807
|
+
if (Array.isArray(originalHandler)) {
|
|
808
|
+
handlers.push(...originalHandler.map(wrapHandler));
|
|
809
|
+
} else {
|
|
810
|
+
handlers.push(wrapHandler(originalHandler));
|
|
811
|
+
}
|
|
812
|
+
const finalConfig = {
|
|
623
813
|
...config,
|
|
624
|
-
handler:
|
|
814
|
+
handler: handlers
|
|
625
815
|
};
|
|
816
|
+
if (config.schema) {
|
|
817
|
+
finalConfig.__sprintMiddlewareSchema = config.schema;
|
|
818
|
+
}
|
|
819
|
+
return finalConfig;
|
|
626
820
|
}
|
|
627
821
|
const Router = () => express.Router();
|
|
628
822
|
exports.Router = Router;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const zod = require("zod");
|
|
4
|
+
function createSprintAuthorizationSchema(options) {
|
|
5
|
+
const defaultSources = ["query:token", "headers:authorization"];
|
|
6
|
+
const sources = options?.sources ? Array.isArray(options.sources) ? options.sources : [options.sources] : defaultSources;
|
|
7
|
+
return zod.z.string().describe(JSON.stringify({ __sprintAuthorization: true, sources }));
|
|
8
|
+
}
|
|
9
|
+
const sprintBuilder = {
|
|
10
|
+
authorization: createSprintAuthorizationSchema
|
|
11
|
+
};
|
|
12
|
+
zod.z.sprint = sprintBuilder;
|
|
13
|
+
const sprint = sprintBuilder;
|
|
4
14
|
function parseSchema(schema, data) {
|
|
5
15
|
const result = schema.safeParse(data);
|
|
6
16
|
if (!result.success) {
|
|
@@ -29,6 +39,47 @@ function defineRouteSchema(schema) {
|
|
|
29
39
|
const result = parseSchema(schema.params, req.params);
|
|
30
40
|
if (!result.success) errors.push(...result.errors.map((e) => ({ location: "params", ...e })));
|
|
31
41
|
}
|
|
42
|
+
if (schema.headers) {
|
|
43
|
+
const result = parseSchema(schema.headers, req.headers);
|
|
44
|
+
if (!result.success) errors.push(...result.errors.map((e) => ({ location: "headers", ...e })));
|
|
45
|
+
}
|
|
46
|
+
if (schema.sprint?.authorization) {
|
|
47
|
+
const authSchema = schema.sprint.authorization;
|
|
48
|
+
const description = authSchema._def?.description;
|
|
49
|
+
let sources = ["query:token", "headers:authorization"];
|
|
50
|
+
if (description) {
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(description);
|
|
53
|
+
if (parsed.__sprintAuthorization && parsed.sources) {
|
|
54
|
+
sources = Array.isArray(parsed.sources) ? parsed.sources : [parsed.sources];
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
let authValue;
|
|
60
|
+
for (const source of sources) {
|
|
61
|
+
const [type, key] = source.split(":");
|
|
62
|
+
if (type === "query") {
|
|
63
|
+
const value = req.query[key];
|
|
64
|
+
if (typeof value === "string" && value.length > 0) {
|
|
65
|
+
authValue = value;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
} else if (type === "headers") {
|
|
69
|
+
const value = req.headers[key.toLowerCase()];
|
|
70
|
+
if (typeof value === "string" && value.length > 0) {
|
|
71
|
+
authValue = value;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(value) && value.length > 0 && typeof value[0] === "string" && value[0].length > 0) {
|
|
75
|
+
authValue = value[0];
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (!authValue) errors.push({ location: "sprint.authorization", path: "authorization", message: "Authorization header or query parameter not found" });
|
|
81
|
+
else req.sprint.authorization = authValue;
|
|
82
|
+
}
|
|
32
83
|
if (errors.length > 0) return res.status(400).json({ error: "Validation failed", details: errors });
|
|
33
84
|
next();
|
|
34
85
|
};
|
|
@@ -40,3 +91,4 @@ Object.defineProperty(exports, "z", {
|
|
|
40
91
|
get: () => zod.z
|
|
41
92
|
});
|
|
42
93
|
exports.defineRouteSchema = defineRouteSchema;
|
|
94
|
+
exports.sprint = sprint;
|
package/dist/esm/index.js
CHANGED
|
@@ -414,6 +414,7 @@ class Sprint {
|
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
};
|
|
417
|
+
let allParams = [];
|
|
417
418
|
if (route.schema?.body && !["GET", "HEAD", "DELETE"].includes(route.method)) {
|
|
418
419
|
try {
|
|
419
420
|
const bodySchema = this.zodSchemaToOpenAPI(route.schema.body);
|
|
@@ -433,11 +434,81 @@ class Sprint {
|
|
|
433
434
|
if (route.schema?.queryParams) {
|
|
434
435
|
try {
|
|
435
436
|
const params = this.zodParamsToOpenAPI(route.schema.queryParams);
|
|
436
|
-
if (params.length > 0)
|
|
437
|
+
if (params.length > 0) allParams.push(...params);
|
|
437
438
|
} catch (e) {
|
|
438
439
|
console.warn("[Sprint] Failed to convert query params schema:", e);
|
|
439
440
|
}
|
|
440
441
|
}
|
|
442
|
+
if (route.schema?.headers) {
|
|
443
|
+
try {
|
|
444
|
+
const headers = this.zodHeadersToOpenAPI(route.schema.headers);
|
|
445
|
+
if (headers.length > 0) allParams.push(...headers);
|
|
446
|
+
} catch (e) {
|
|
447
|
+
console.warn("[Sprint] Failed to convert headers schema:", e);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (this.openapi.generateOnBuild) {
|
|
451
|
+
try {
|
|
452
|
+
const routeMiddlewares = this.getMiddlewaresForRoute(route.path);
|
|
453
|
+
for (const mw of this.loadedMiddlewares) {
|
|
454
|
+
const includePatterns = Array.isArray(mw.include) ? mw.include : [mw.include || "/**"];
|
|
455
|
+
const excludePatterns = Array.isArray(mw.exclude) ? mw.exclude : mw.exclude ? [mw.exclude] : [];
|
|
456
|
+
const isIncluded = matchesPatterns(includePatterns, route.path);
|
|
457
|
+
const isExcluded = excludePatterns.length > 0 && matchesPatterns(excludePatterns, route.path);
|
|
458
|
+
if (isIncluded && !isExcluded && mw.__sprintMiddlewareSchema) {
|
|
459
|
+
const mwSchema = mw.__sprintMiddlewareSchema;
|
|
460
|
+
if (mwSchema.queryParams) {
|
|
461
|
+
const params = this.zodParamsToOpenAPI(mwSchema.queryParams);
|
|
462
|
+
if (params.length > 0) allParams.push(...params);
|
|
463
|
+
}
|
|
464
|
+
if (mwSchema.headers) {
|
|
465
|
+
const headers = this.zodHeadersToOpenAPI(mwSchema.headers);
|
|
466
|
+
if (headers.length > 0) allParams.push(...headers);
|
|
467
|
+
}
|
|
468
|
+
if (mwSchema.sprint?.authorization) {
|
|
469
|
+
const authSchema = mwSchema.sprint.authorization;
|
|
470
|
+
const description = authSchema._def?.description;
|
|
471
|
+
let sources = ["query:token", "headers:authorization"];
|
|
472
|
+
if (description) {
|
|
473
|
+
try {
|
|
474
|
+
const parsed = JSON.parse(description);
|
|
475
|
+
if (parsed.__sprintAuthorization && parsed.sources) {
|
|
476
|
+
sources = Array.isArray(parsed.sources) ? parsed.sources : [parsed.sources];
|
|
477
|
+
}
|
|
478
|
+
} catch {
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
for (const source of sources) {
|
|
482
|
+
const [type, key] = source.split(":");
|
|
483
|
+
if (type === "query") {
|
|
484
|
+
allParams.push({
|
|
485
|
+
name: key,
|
|
486
|
+
in: "query",
|
|
487
|
+
required: true,
|
|
488
|
+
schema: { type: "string" }
|
|
489
|
+
});
|
|
490
|
+
} else if (type === "headers") {
|
|
491
|
+
allParams.push({
|
|
492
|
+
name: key,
|
|
493
|
+
in: "header",
|
|
494
|
+
required: true,
|
|
495
|
+
schema: { type: "string" }
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
} catch (e) {
|
|
503
|
+
console.warn("[Sprint] Failed to add middleware schemas to OpenAPI:", e);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
if (allParams.length > 0) {
|
|
507
|
+
const uniqueParams = allParams.filter(
|
|
508
|
+
(param, index, self) => index === self.findIndex((p) => p.name === param.name && p.in === param.in)
|
|
509
|
+
);
|
|
510
|
+
routeSpec.parameters = uniqueParams;
|
|
511
|
+
}
|
|
441
512
|
paths[route.path][method] = routeSpec;
|
|
442
513
|
}
|
|
443
514
|
return {
|
|
@@ -511,6 +582,33 @@ class Sprint {
|
|
|
511
582
|
}
|
|
512
583
|
return params;
|
|
513
584
|
}
|
|
585
|
+
zodHeadersToOpenAPI(schema) {
|
|
586
|
+
if (!schema) return [];
|
|
587
|
+
const headers = [];
|
|
588
|
+
const shape = schema.shape || schema._def?.shape();
|
|
589
|
+
if (!shape) return [];
|
|
590
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
591
|
+
const zodDef = value._def;
|
|
592
|
+
const typeName = zodDef?.typeName;
|
|
593
|
+
let paramSchema = {};
|
|
594
|
+
if (typeName === "ZodString") {
|
|
595
|
+
paramSchema = { type: "string" };
|
|
596
|
+
} else if (typeName === "ZodNumber") {
|
|
597
|
+
paramSchema = { type: "number" };
|
|
598
|
+
} else if (typeName === "ZodBoolean") {
|
|
599
|
+
paramSchema = { type: "boolean" };
|
|
600
|
+
} else {
|
|
601
|
+
paramSchema = { type: "string" };
|
|
602
|
+
}
|
|
603
|
+
headers.push({
|
|
604
|
+
name: key,
|
|
605
|
+
in: "header",
|
|
606
|
+
required: !zodDef?.isOptional,
|
|
607
|
+
schema: paramSchema
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
return headers;
|
|
611
|
+
}
|
|
514
612
|
// HTTP Methods (prefix is applied automatically).
|
|
515
613
|
get(path2, handler) {
|
|
516
614
|
return this.app.get(this.applyPrefix(path2), handler);
|
|
@@ -587,6 +685,88 @@ class Sprint {
|
|
|
587
685
|
});
|
|
588
686
|
}
|
|
589
687
|
}
|
|
688
|
+
function createSchemaValidationMiddleware(schema) {
|
|
689
|
+
return (req, res, next) => {
|
|
690
|
+
const errors = [];
|
|
691
|
+
if (schema.body) {
|
|
692
|
+
const result = schema.body.safeParse(req.body);
|
|
693
|
+
if (!result.success) {
|
|
694
|
+
errors.push(...result.error.issues.map((issue) => ({
|
|
695
|
+
location: "body",
|
|
696
|
+
path: issue.path.join("."),
|
|
697
|
+
message: issue.message
|
|
698
|
+
})));
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
if (schema.queryParams) {
|
|
702
|
+
const result = schema.queryParams.safeParse(req.query);
|
|
703
|
+
if (!result.success) {
|
|
704
|
+
errors.push(...result.error.issues.map((issue) => ({
|
|
705
|
+
location: "queryParams",
|
|
706
|
+
path: issue.path.join("."),
|
|
707
|
+
message: issue.message
|
|
708
|
+
})));
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
if (schema.params) {
|
|
712
|
+
const result = schema.params.safeParse(req.params);
|
|
713
|
+
if (!result.success) {
|
|
714
|
+
errors.push(...result.error.issues.map((issue) => ({
|
|
715
|
+
location: "params",
|
|
716
|
+
path: issue.path.join("."),
|
|
717
|
+
message: issue.message
|
|
718
|
+
})));
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
if (schema.headers) {
|
|
722
|
+
const result = schema.headers.safeParse(req.headers);
|
|
723
|
+
if (!result.success) {
|
|
724
|
+
errors.push(...result.error.issues.map((issue) => ({
|
|
725
|
+
location: "headers",
|
|
726
|
+
path: issue.path.join("."),
|
|
727
|
+
message: issue.message
|
|
728
|
+
})));
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
if (schema.sprint?.authorization) {
|
|
732
|
+
const authSchema = schema.sprint.authorization;
|
|
733
|
+
const description = authSchema._def?.description;
|
|
734
|
+
let sources = ["query:token", "headers:authorization"];
|
|
735
|
+
if (description) {
|
|
736
|
+
try {
|
|
737
|
+
const parsed = JSON.parse(description);
|
|
738
|
+
if (parsed.__sprintAuthorization && parsed.sources) sources = Array.isArray(parsed.sources) ? parsed.sources : [parsed.sources];
|
|
739
|
+
} catch {
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
let authValue;
|
|
743
|
+
for (const source of sources) {
|
|
744
|
+
const [type, key] = source.split(":");
|
|
745
|
+
if (type === "query") {
|
|
746
|
+
const value = req.query[key];
|
|
747
|
+
if (typeof value === "string" && value.length > 0) {
|
|
748
|
+
authValue = value;
|
|
749
|
+
break;
|
|
750
|
+
}
|
|
751
|
+
} else if (type === "headers") {
|
|
752
|
+
const value = req.headers[key.toLowerCase()];
|
|
753
|
+
if (typeof value === "string" && value.length > 0) {
|
|
754
|
+
authValue = value;
|
|
755
|
+
break;
|
|
756
|
+
}
|
|
757
|
+
if (Array.isArray(value) && value.length > 0 && typeof value[0] === "string" && value[0].length > 0) {
|
|
758
|
+
authValue = value[0];
|
|
759
|
+
break;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
if (!authValue) errors.push({ location: "sprint.authorization", path: "authorization", message: "Authorization header or query parameter not found" });
|
|
764
|
+
else req.sprint.authorization = authValue;
|
|
765
|
+
}
|
|
766
|
+
if (errors.length > 0) return res.status(400).json({ error: "Validation failed", details: errors });
|
|
767
|
+
next();
|
|
768
|
+
};
|
|
769
|
+
}
|
|
590
770
|
function defineMiddleware(config) {
|
|
591
771
|
const wrapHandler = (handler) => {
|
|
592
772
|
return (req, res, next) => {
|
|
@@ -594,10 +774,24 @@ function defineMiddleware(config) {
|
|
|
594
774
|
if (result instanceof Promise) result.catch(next);
|
|
595
775
|
};
|
|
596
776
|
};
|
|
597
|
-
|
|
777
|
+
const handlers = [];
|
|
778
|
+
if (config.schema) {
|
|
779
|
+
handlers.push(createSchemaValidationMiddleware(config.schema));
|
|
780
|
+
}
|
|
781
|
+
const originalHandler = config.handler;
|
|
782
|
+
if (Array.isArray(originalHandler)) {
|
|
783
|
+
handlers.push(...originalHandler.map(wrapHandler));
|
|
784
|
+
} else {
|
|
785
|
+
handlers.push(wrapHandler(originalHandler));
|
|
786
|
+
}
|
|
787
|
+
const finalConfig = {
|
|
598
788
|
...config,
|
|
599
|
-
handler:
|
|
789
|
+
handler: handlers
|
|
600
790
|
};
|
|
791
|
+
if (config.schema) {
|
|
792
|
+
finalConfig.__sprintMiddlewareSchema = config.schema;
|
|
793
|
+
}
|
|
794
|
+
return finalConfig;
|
|
601
795
|
}
|
|
602
796
|
const Router = () => Router$1();
|
|
603
797
|
export {
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { z as z2 } from "zod";
|
|
3
|
+
function createSprintAuthorizationSchema(options) {
|
|
4
|
+
const defaultSources = ["query:token", "headers:authorization"];
|
|
5
|
+
const sources = options?.sources ? Array.isArray(options.sources) ? options.sources : [options.sources] : defaultSources;
|
|
6
|
+
return z.string().describe(JSON.stringify({ __sprintAuthorization: true, sources }));
|
|
7
|
+
}
|
|
8
|
+
const sprintBuilder = {
|
|
9
|
+
authorization: createSprintAuthorizationSchema
|
|
10
|
+
};
|
|
11
|
+
z.sprint = sprintBuilder;
|
|
12
|
+
const sprint = sprintBuilder;
|
|
2
13
|
function parseSchema(schema, data) {
|
|
3
14
|
const result = schema.safeParse(data);
|
|
4
15
|
if (!result.success) {
|
|
@@ -27,6 +38,47 @@ function defineRouteSchema(schema) {
|
|
|
27
38
|
const result = parseSchema(schema.params, req.params);
|
|
28
39
|
if (!result.success) errors.push(...result.errors.map((e) => ({ location: "params", ...e })));
|
|
29
40
|
}
|
|
41
|
+
if (schema.headers) {
|
|
42
|
+
const result = parseSchema(schema.headers, req.headers);
|
|
43
|
+
if (!result.success) errors.push(...result.errors.map((e) => ({ location: "headers", ...e })));
|
|
44
|
+
}
|
|
45
|
+
if (schema.sprint?.authorization) {
|
|
46
|
+
const authSchema = schema.sprint.authorization;
|
|
47
|
+
const description = authSchema._def?.description;
|
|
48
|
+
let sources = ["query:token", "headers:authorization"];
|
|
49
|
+
if (description) {
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(description);
|
|
52
|
+
if (parsed.__sprintAuthorization && parsed.sources) {
|
|
53
|
+
sources = Array.isArray(parsed.sources) ? parsed.sources : [parsed.sources];
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
let authValue;
|
|
59
|
+
for (const source of sources) {
|
|
60
|
+
const [type, key] = source.split(":");
|
|
61
|
+
if (type === "query") {
|
|
62
|
+
const value = req.query[key];
|
|
63
|
+
if (typeof value === "string" && value.length > 0) {
|
|
64
|
+
authValue = value;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
} else if (type === "headers") {
|
|
68
|
+
const value = req.headers[key.toLowerCase()];
|
|
69
|
+
if (typeof value === "string" && value.length > 0) {
|
|
70
|
+
authValue = value;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(value) && value.length > 0 && typeof value[0] === "string" && value[0].length > 0) {
|
|
74
|
+
authValue = value[0];
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!authValue) errors.push({ location: "sprint.authorization", path: "authorization", message: "Authorization header or query parameter not found" });
|
|
80
|
+
else req.sprint.authorization = authValue;
|
|
81
|
+
}
|
|
30
82
|
if (errors.length > 0) return res.status(400).json({ error: "Validation failed", details: errors });
|
|
31
83
|
next();
|
|
32
84
|
};
|
|
@@ -35,5 +87,6 @@ function defineRouteSchema(schema) {
|
|
|
35
87
|
}
|
|
36
88
|
export {
|
|
37
89
|
defineRouteSchema,
|
|
38
|
-
|
|
90
|
+
sprint,
|
|
91
|
+
z2 as z
|
|
39
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAyC,MAAM,SAAS,CAAC;AA6FlF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CA+B3E"}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { RequestHandler } from 'express';
|
|
2
2
|
import { z, ZodSchema as ZodSchemaType, ZodTypeDef } from 'zod';
|
|
3
3
|
export { z };
|
|
4
|
+
export type AuthorizationSource = `query:${string}` | `headers:${string}`;
|
|
5
|
+
export interface SprintAuthorizationOptions {
|
|
6
|
+
sources?: AuthorizationSource | AuthorizationSource[];
|
|
7
|
+
}
|
|
8
|
+
declare function createSprintAuthorizationSchema(options?: SprintAuthorizationOptions): ZodSchemaType<string, ZodTypeDef, string>;
|
|
9
|
+
export declare const sprint: {
|
|
10
|
+
authorization: typeof createSprintAuthorizationSchema;
|
|
11
|
+
};
|
|
4
12
|
export interface RouteSchemaOptions {
|
|
5
13
|
body?: ZodSchemaType<any, ZodTypeDef, any>;
|
|
6
14
|
queryParams?: ZodSchemaType<any, ZodTypeDef, any>;
|
|
7
15
|
params?: ZodSchemaType<any, ZodTypeDef, any>;
|
|
16
|
+
headers?: ZodSchemaType<any, ZodTypeDef, any>;
|
|
17
|
+
sprint?: {
|
|
18
|
+
authorization?: ZodSchemaType<string, ZodTypeDef, string>;
|
|
19
|
+
};
|
|
8
20
|
}
|
|
9
21
|
export declare function defineRouteSchema<T extends RouteSchemaOptions>(schema: T): RequestHandler;
|
|
10
22
|
export type { ZodSchema, ZodMiddlewareOptions } from './types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE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,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/modules/schemas/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAEvC,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/modules/schemas/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAEvC,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE;QACL,aAAa,CAAC,EAAE,SAAS,CAAC;KAC7B,CAAC;CACL"}
|
package/dist/types/sprint.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare class Sprint {
|
|
|
36
36
|
private generateOpenAPISpec;
|
|
37
37
|
private zodSchemaToOpenAPI;
|
|
38
38
|
private zodParamsToOpenAPI;
|
|
39
|
+
private zodHeadersToOpenAPI;
|
|
39
40
|
get(path: string, handler: Handler): express.Application;
|
|
40
41
|
post(path: string, handler: Handler): express.Application;
|
|
41
42
|
put(path: string, handler: Handler): express.Application;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprint.d.ts","sourceRoot":"","sources":["../../src/sprint.ts"],"names":[],"mappings":"AASA,OA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, Response, NextFunction, RequestHandler } from 'express';
|
|
2
|
+
import { ZodSchema } from './modules/schemas/types';
|
|
2
3
|
export type AsyncRequestHandler = (req: Request, res: Response, next: NextFunction) => Promise<any>;
|
|
3
4
|
export type Handler = (req: Request, res: Response, next: NextFunction) => any;
|
|
4
5
|
export type AuthorizationSource = `query:${string}` | `headers:${string}`;
|
|
5
6
|
export interface SprintRequest {
|
|
6
7
|
getAuthorization: (sources?: AuthorizationSource | AuthorizationSource[]) => string | undefined;
|
|
8
|
+
authorization?: string;
|
|
7
9
|
}
|
|
8
10
|
export type SprintResponse = Response;
|
|
9
11
|
declare global {
|
|
@@ -14,6 +16,15 @@ declare global {
|
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
}
|
|
19
|
+
export interface MiddlewareSchema {
|
|
20
|
+
body?: ZodSchema;
|
|
21
|
+
queryParams?: ZodSchema;
|
|
22
|
+
params?: ZodSchema;
|
|
23
|
+
headers?: ZodSchema;
|
|
24
|
+
sprint?: {
|
|
25
|
+
authorization?: ZodSchema;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
17
28
|
/**
|
|
18
29
|
* Configuration for a middleware defined in the middlewares folder.
|
|
19
30
|
* Export this from your middleware file using `defineMiddleware()`.
|
|
@@ -43,6 +54,11 @@ export interface MiddlewareConfig {
|
|
|
43
54
|
priority?: number;
|
|
44
55
|
/** Optional name for logging purposes */
|
|
45
56
|
name?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Schema for request validation and OpenAPI generation.
|
|
59
|
+
* Supports body, queryParams, params, headers, and sprint.authorization.
|
|
60
|
+
*/
|
|
61
|
+
schema?: MiddlewareSchema;
|
|
46
62
|
}
|
|
47
63
|
export interface LoadedMiddleware extends MiddlewareConfig {
|
|
48
64
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE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