@creator.co/wapi 1.3.5 → 1.3.7
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/package.json +1 -1
- package/dist/src/Config/Configuration.d.ts +6 -0
- package/dist/src/Config/Configuration.js +10 -0
- package/dist/src/Config/Configuration.js.map +1 -1
- package/dist/src/Server/Router.d.ts +9 -7
- package/dist/src/Server/Router.js.map +1 -1
- package/dist/src/Validation/Validator.d.ts +1 -1
- package/dist/src/Validation/Validator.js.map +1 -1
- package/package.json +1 -1
- package/src/Config/Configuration.ts +11 -0
- package/src/Server/Router.ts +9 -7
- package/src/Validation/Validator.ts +1 -1
package/dist/package.json
CHANGED
|
@@ -73,6 +73,12 @@ export default class Configuration<T extends ConfigurationSchema> {
|
|
|
73
73
|
* @type {string}
|
|
74
74
|
*/
|
|
75
75
|
private readonly remotePrefix;
|
|
76
|
+
/**
|
|
77
|
+
* Indicates if config is local and should attempt to override
|
|
78
|
+
* remote values from local.
|
|
79
|
+
* @type {string}
|
|
80
|
+
*/
|
|
81
|
+
private static readonly isLocal;
|
|
76
82
|
/**
|
|
77
83
|
* Constructs a new instance of the class.
|
|
78
84
|
* @param {T} schema - The schema object.
|
|
@@ -89,6 +89,10 @@ var Configuration = /** @class */ (function () {
|
|
|
89
89
|
case 0:
|
|
90
90
|
propString = propName;
|
|
91
91
|
propSchema = this.schema[propString];
|
|
92
|
+
// check for local override
|
|
93
|
+
if (Configuration.isLocal && process.env[propString] !== undefined) {
|
|
94
|
+
console.log("Overriding remote variable ".concat(propString, " with local value!"));
|
|
95
|
+
}
|
|
92
96
|
v = this.getCachedValue(propString);
|
|
93
97
|
_a = v;
|
|
94
98
|
if (_a) return [3 /*break*/, 2];
|
|
@@ -130,6 +134,12 @@ var Configuration = /** @class */ (function () {
|
|
|
130
134
|
Configuration.prototype.resetCache = function () {
|
|
131
135
|
cacheStore = new MemCache();
|
|
132
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* Indicates if config is local and should attempt to override
|
|
139
|
+
* remote values from local.
|
|
140
|
+
* @type {string}
|
|
141
|
+
*/
|
|
142
|
+
Configuration.isLocal = process.env.NODE_ENV == 'local';
|
|
133
143
|
return Configuration;
|
|
134
144
|
}());
|
|
135
145
|
exports.default = Configuration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../src/Config/Configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAsC;AACtC,+CAAgD;AAEhD,mDAAkE;AAElE,qCAAqC;AACrC,kCAAkC;AAClC;;;GAGG;AACH,IAAI,UAAU,GAAG,IAAI,QAAQ,EAAE,CAAA;AA2E/B;;;GAGG;AACH;
|
|
1
|
+
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../src/Config/Configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAsC;AACtC,+CAAgD;AAEhD,mDAAkE;AAElE,qCAAqC;AACrC,kCAAkC;AAClC;;;GAGG;AACH,IAAI,UAAU,GAAG,IAAI,QAAQ,EAAE,CAAA;AA2E/B;;;GAGG;AACH;IAkBE;;;;;OAKG;IACH,uBAAY,MAAS,EAAE,YAAoB;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED;;;;OAIG;IACI,2BAAG,GAAV,UAAW,QAAsD;QAC/D,IAAM,UAAU,GAAG,QAAkB,CAAA;QACrC,IAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QAC1C,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;QACvC,CAAC;YACC,CAAC;gBACD,IAAI,wBAAc,CAChB,UAAU,EACV,gCAAe,CAAC,KAAK,EACrB,CAAC,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AAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACjC,CAAC;IAED;;;;;;OAMG;IACK,kCAAU,GAAlB,UAAmB,QAAgB,EAAE,KAAU,EAAE,MAAqB;QAArB,uBAAA,EAAA,aAAqB;QACpE,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;IACpE,CAAC;IAED;;;OAGG;IACK,kCAAU,GAAlB;QACE,UAAU,GAAG,IAAI,QAAQ,EAAE,CAAA;IAC7B,CAAC;IA3FD;;;;OAIG;IACqB,qBAAO,GAAY,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAA;IAuF5E,oBAAC;CAAA,AAvGD,IAuGC;kBAvGoB,aAAa"}
|
|
@@ -12,7 +12,9 @@ import Transaction, { TransactionConfig, TransactionExecution, StringMap } from
|
|
|
12
12
|
* @property {string} path - The path of the route.
|
|
13
13
|
* @property {string} method - The HTTP method of the route.
|
|
14
14
|
* @property {TransactionExecution<Transaction<InputType, OutputType | ResponseErrorType>, OutputType | ResponseErrorType>} handler - The handler function for the route.
|
|
15
|
-
* @property {z.ZodObject<any>}
|
|
15
|
+
* @property {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}[inputSchema] - The input schema for validating the input data.
|
|
16
|
+
* @property {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}[pathSchema] - The path schema for validating the path data.
|
|
17
|
+
* @property {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}[querySchema] - The query schema for validating the query data.
|
|
16
18
|
*/
|
|
17
19
|
export interface Route<InputType = any, OutputType = any, PathParamsType = StringMap, QueryParamsType = StringMap> {
|
|
18
20
|
/**
|
|
@@ -36,23 +38,23 @@ export interface Route<InputType = any, OutputType = any, PathParamsType = Strin
|
|
|
36
38
|
* An optional input schema for validating the structure of the input data.
|
|
37
39
|
* Description placeholder
|
|
38
40
|
*
|
|
39
|
-
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
41
|
+
* @type {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}
|
|
40
42
|
*/
|
|
41
|
-
inputSchema?: z.ZodObject<any> | z.ZodUnion<any>;
|
|
43
|
+
inputSchema?: z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>;
|
|
42
44
|
/**
|
|
43
45
|
* An optional input schema for validating the structure of the path params.
|
|
44
46
|
* Description placeholder
|
|
45
47
|
*
|
|
46
|
-
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
48
|
+
* @type {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}
|
|
47
49
|
*/
|
|
48
|
-
pathSchema?: z.ZodObject<any> | z.ZodUnion<any>;
|
|
50
|
+
pathSchema?: z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>;
|
|
49
51
|
/**
|
|
50
52
|
* An optional input schema for validating the structure of the query params.
|
|
51
53
|
* Description placeholder
|
|
52
54
|
*
|
|
53
|
-
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
55
|
+
* @type {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}
|
|
54
56
|
*/
|
|
55
|
-
querySchema?: z.ZodObject<any> | z.ZodUnion<any>;
|
|
57
|
+
querySchema?: z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>;
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Represents the configuration options for a router.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/Server/Router.ts"],"names":[],"mappings":";;AAKA,yDAAmD;AACnD,uCAAiC;AAGjC,sCAAgC;
|
|
1
|
+
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/Server/Router.ts"],"names":[],"mappings":";;AAKA,yDAAmD;AACnD,uCAAiC;AAGjC,sCAAgC;AA+HhC;;GAEG;AACH;IAUE;;;;OAIG;IACH,gBAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,yBAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAM,CAAC,MAAM,CAAC,CAAA;IACrF,CAAC;IAED;;;OAGG;IACI,0BAAS,GAAhB;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;IAChC,CAAC;IAED;;;OAGG;IACK,4BAAW,GAAnB;QACE,OAAO,eAAK,CAAC,qBAAqB,EAAE,CAAA;IACtC,CAAC;IACH,aAAC;AAAD,CAAC,AAnCD,IAmCC"}
|
|
@@ -13,5 +13,5 @@ export default class Validator {
|
|
|
13
13
|
* @param {z.ZodObject<any> | z.ZodUnion<any>} schema - The schema to validate against.
|
|
14
14
|
* @returns {boolean | Response<ResponseErrorType>} - Returns either true if the data is valid or a Response object with an error message if validation fails.
|
|
15
15
|
*/
|
|
16
|
-
static validateSchema(data: any, schema: z.ZodObject<any> | z.ZodUnion<any>): boolean | Response<ResponseErrorType>;
|
|
16
|
+
static validateSchema(data: any, schema: z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>): boolean | Response<ResponseErrorType>;
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Validator.js","sourceRoot":"","sources":["../../../src/Validation/Validator.ts"],"names":[],"mappings":";;AAAA,2BAAuB;AAEvB,4CAA6D;AAC7D,sCAAgC;AAEhC;;;;;GAKG;AACH;IAAA;IAgCA,CAAC;IA/BC;;;;;OAKG;IACW,wBAAc,GAA5B,UACE,IAAS,EACT,
|
|
1
|
+
{"version":3,"file":"Validator.js","sourceRoot":"","sources":["../../../src/Validation/Validator.ts"],"names":[],"mappings":";;AAAA,2BAAuB;AAEvB,4CAA6D;AAC7D,sCAAgC;AAEhC;;;;;GAKG;AACH;IAAA;IAgCA,CAAC;IA/BC;;;;;OAKG;IACW,wBAAc,GAA5B,UACE,IAAS,EACT,MAAwE;QAExE,IAAI,KAAK,EAAE,cAAc,CAAA;QAEzB,yCAAyC;QACzC,IAAI;YACF,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAkB,CAAA;SACrD;QAAC,OAAO,GAAqB,EAAE;YAC9B,IAAI,GAAG,YAAY,OAAC,CAAC,QAAQ;gBAAE,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;;gBACzD,KAAK,GAAG,2BAA2B,CAAA,CAAC,8BAA8B;SACxE;QAED,mBAAmB;QACnB,IAAI,CAAC,cAAc,IAAI,KAAK,EAAE;YAC5B,OAAO,kBAAQ,CAAC,kBAAkB,CAChC,iBAAO,CAAC,2BAA2B,EACnC,iBAAO,CAAC,sBAAsB,EAC9B,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAA;SACF;aAAM;YACL,OAAO,IAAI,CAAA;SACZ;IACH,CAAC;IACH,gBAAC;AAAD,CAAC,AAhCD,IAgCC"}
|
package/package.json
CHANGED
|
@@ -99,6 +99,12 @@ export default class Configuration<T extends ConfigurationSchema> {
|
|
|
99
99
|
* @type {string}
|
|
100
100
|
*/
|
|
101
101
|
private readonly remotePrefix: string
|
|
102
|
+
/**
|
|
103
|
+
* Indicates if config is local and should attempt to override
|
|
104
|
+
* remote values from local.
|
|
105
|
+
* @type {string}
|
|
106
|
+
*/
|
|
107
|
+
private static readonly isLocal: boolean = process.env.NODE_ENV == 'local'
|
|
102
108
|
|
|
103
109
|
/**
|
|
104
110
|
* Constructs a new instance of the class.
|
|
@@ -140,6 +146,11 @@ export default class Configuration<T extends ConfigurationSchema> {
|
|
|
140
146
|
public async asyncGet(propName: keyof OmitByValueType<ExtractRemote<T>, null>): Promise<any> {
|
|
141
147
|
const propString = propName as string
|
|
142
148
|
const propSchema = this.schema[propString]
|
|
149
|
+
// check for local override
|
|
150
|
+
if (Configuration.isLocal && process.env[propString] !== undefined) {
|
|
151
|
+
console.log(`Overriding remote variable ${propString} with local value!`)
|
|
152
|
+
}
|
|
153
|
+
// remote
|
|
143
154
|
let v = this.getCachedValue(propString)
|
|
144
155
|
v =
|
|
145
156
|
v ||
|
package/src/Server/Router.ts
CHANGED
|
@@ -21,7 +21,9 @@ import Transaction, {
|
|
|
21
21
|
* @property {string} path - The path of the route.
|
|
22
22
|
* @property {string} method - The HTTP method of the route.
|
|
23
23
|
* @property {TransactionExecution<Transaction<InputType, OutputType | ResponseErrorType>, OutputType | ResponseErrorType>} handler - The handler function for the route.
|
|
24
|
-
* @property {z.ZodObject<any>}
|
|
24
|
+
* @property {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}[inputSchema] - The input schema for validating the input data.
|
|
25
|
+
* @property {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}[pathSchema] - The path schema for validating the path data.
|
|
26
|
+
* @property {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}[querySchema] - The query schema for validating the query data.
|
|
25
27
|
*/
|
|
26
28
|
export interface Route<
|
|
27
29
|
InputType = any,
|
|
@@ -59,25 +61,25 @@ export interface Route<
|
|
|
59
61
|
* An optional input schema for validating the structure of the input data.
|
|
60
62
|
* Description placeholder
|
|
61
63
|
*
|
|
62
|
-
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
64
|
+
* @type {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}
|
|
63
65
|
*/
|
|
64
|
-
inputSchema?: z.ZodObject<any> | z.ZodUnion<any>
|
|
66
|
+
inputSchema?: z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>
|
|
65
67
|
|
|
66
68
|
/**
|
|
67
69
|
* An optional input schema for validating the structure of the path params.
|
|
68
70
|
* Description placeholder
|
|
69
71
|
*
|
|
70
|
-
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
72
|
+
* @type {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}
|
|
71
73
|
*/
|
|
72
|
-
pathSchema?: z.ZodObject<any> | z.ZodUnion<any>
|
|
74
|
+
pathSchema?: z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>
|
|
73
75
|
|
|
74
76
|
/**
|
|
75
77
|
* An optional input schema for validating the structure of the query params.
|
|
76
78
|
* Description placeholder
|
|
77
79
|
*
|
|
78
|
-
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
80
|
+
* @type {?z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>}
|
|
79
81
|
*/
|
|
80
|
-
querySchema?: z.ZodObject<any> | z.ZodUnion<any>
|
|
82
|
+
querySchema?: z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
/**
|
|
@@ -18,7 +18,7 @@ export default class Validator {
|
|
|
18
18
|
*/
|
|
19
19
|
public static validateSchema(
|
|
20
20
|
data: any,
|
|
21
|
-
schema: z.ZodObject<any> | z.ZodUnion<any>
|
|
21
|
+
schema: z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>
|
|
22
22
|
): boolean | Response<ResponseErrorType> {
|
|
23
23
|
let error, validatedInput
|
|
24
24
|
|