@catbee/utils 0.0.8-rc.1 → 0.0.8-rc.3
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/build/{esnext → cjs}/config.d.ts +0 -1
- package/build/{src → cjs}/config.js +0 -1
- package/build/{esnext → cjs}/index.d.ts +0 -1
- package/build/{src → cjs}/index.js +0 -1
- package/build/{esnext → cjs}/servers/server.builder.d.ts +0 -1
- package/build/{src → cjs}/servers/server.builder.js +10 -13
- package/build/{src → cjs}/servers/server.d.ts +0 -1
- package/build/{src → cjs}/servers/server.js +83 -75
- package/build/{src → cjs}/types/api-response.d.ts +0 -1
- package/build/{src → cjs}/types/api-response.js +0 -1
- package/build/{src → cjs}/types/index.d.ts +0 -1
- package/build/{src → cjs}/types/index.js +0 -1
- package/build/{src → cjs}/types/server.d.ts +0 -1
- package/build/{src → cjs}/types/server.js +0 -1
- package/build/{src → cjs}/utils/array.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/array.utils.js +0 -1
- package/build/{src → cjs}/utils/async.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/async.utils.js +2 -3
- package/build/{esnext → cjs}/utils/cache.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/cache.utils.js +7 -6
- package/build/{esnext → cjs}/utils/context-store.utils.d.ts +1 -2
- package/build/{src → cjs}/utils/context-store.utils.js +10 -9
- package/build/{esnext → cjs}/utils/crypto.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/crypto.utils.js +5 -3
- package/build/{src → cjs}/utils/date.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/date.utils.js +1 -2
- package/build/{src → cjs}/utils/decorators.utils.d.ts +30 -27
- package/build/{src → cjs}/utils/decorators.utils.js +169 -30
- package/build/{esnext → cjs}/utils/dir.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/dir.utils.js +6 -7
- package/build/{esnext → cjs}/utils/env.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/env.utils.js +5 -8
- package/build/{src → cjs}/utils/exception.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/exception.utils.js +2 -1
- package/build/{src → cjs}/utils/fs.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/fs.utils.js +12 -13
- package/build/{esnext → cjs}/utils/http-status-codes.d.ts +0 -1
- package/build/{src → cjs}/utils/http-status-codes.js +0 -1
- package/build/{esnext → cjs}/utils/id.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/id.utils.js +0 -1
- package/build/{src → cjs}/utils/logger.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/logger.utils.js +10 -6
- package/build/{esnext → cjs}/utils/middleware.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/middleware.utils.js +16 -17
- package/build/{esnext → cjs}/utils/obj.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/obj.utils.js +1 -2
- package/build/{src → cjs}/utils/performance.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/performance.utils.js +6 -4
- package/build/{esnext → cjs}/utils/request.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/request.utils.js +7 -3
- package/build/{esnext → cjs}/utils/response.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/response.utils.js +42 -28
- package/build/{esnext → cjs}/utils/stream.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/stream.utils.js +0 -1
- package/build/{esnext → cjs}/utils/string.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/string.utils.js +0 -1
- package/build/{src → cjs}/utils/type.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/type.utils.js +2 -3
- package/build/{src → cjs}/utils/url.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/url.utils.js +8 -9
- package/build/{src → cjs}/utils/validate.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/validate.utils.js +2 -3
- package/build/esm/config.d.ts +0 -1
- package/build/esm/config.js +6 -7
- package/build/esm/index.d.ts +0 -1
- package/build/esm/index.js +0 -1
- package/build/esm/servers/server.builder.d.ts +0 -1
- package/build/esm/servers/server.builder.js +99 -147
- package/build/esm/servers/server.d.ts +0 -1
- package/build/esm/servers/server.js +591 -876
- package/build/esm/types/api-response.d.ts +0 -1
- package/build/esm/types/api-response.js +0 -1
- package/build/esm/types/index.d.ts +0 -1
- package/build/esm/types/index.js +0 -1
- package/build/esm/types/server.d.ts +0 -1
- package/build/esm/types/server.js +0 -1
- package/build/esm/utils/array.utils.d.ts +0 -1
- package/build/esm/utils/array.utils.js +48 -86
- package/build/esm/utils/async.utils.d.ts +0 -1
- package/build/esm/utils/async.utils.js +247 -524
- package/build/esm/utils/cache.utils.d.ts +0 -1
- package/build/esm/utils/cache.utils.js +96 -301
- package/build/esm/utils/context-store.utils.d.ts +1 -2
- package/build/esm/utils/context-store.utils.js +62 -79
- package/build/esm/utils/crypto.utils.d.ts +0 -1
- package/build/esm/utils/crypto.utils.js +78 -175
- package/build/esm/utils/date.utils.d.ts +0 -1
- package/build/esm/utils/date.utils.js +47 -53
- package/build/esm/utils/decorators.utils.d.ts +30 -27
- package/build/esm/utils/decorators.utils.js +417 -461
- package/build/esm/utils/dir.utils.d.ts +0 -1
- package/build/esm/utils/dir.utils.js +264 -786
- package/build/esm/utils/env.utils.d.ts +0 -1
- package/build/esm/utils/env.utils.js +180 -271
- package/build/esm/utils/exception.utils.d.ts +0 -1
- package/build/esm/utils/exception.utils.js +112 -289
- package/build/esm/utils/fs.utils.d.ts +0 -1
- package/build/esm/utils/fs.utils.js +169 -401
- package/build/esm/utils/http-status-codes.d.ts +0 -1
- package/build/esm/utils/http-status-codes.js +0 -1
- package/build/esm/utils/id.utils.d.ts +0 -1
- package/build/esm/utils/id.utils.js +5 -9
- package/build/esm/utils/logger.utils.d.ts +0 -1
- package/build/esm/utils/logger.utils.js +34 -71
- package/build/esm/utils/middleware.utils.d.ts +0 -1
- package/build/esm/utils/middleware.utils.js +65 -155
- package/build/esm/utils/obj.utils.d.ts +0 -1
- package/build/esm/utils/obj.utils.js +69 -176
- package/build/esm/utils/performance.utils.d.ts +0 -1
- package/build/esm/utils/performance.utils.js +92 -195
- package/build/esm/utils/request.utils.d.ts +0 -1
- package/build/esm/utils/request.utils.js +41 -74
- package/build/esm/utils/response.utils.d.ts +0 -1
- package/build/esm/utils/response.utils.js +84 -107
- package/build/esm/utils/stream.utils.d.ts +0 -1
- package/build/esm/utils/stream.utils.js +38 -113
- package/build/esm/utils/string.utils.d.ts +0 -1
- package/build/esm/utils/string.utils.js +6 -11
- package/build/esm/utils/type.utils.d.ts +0 -1
- package/build/esm/utils/type.utils.js +8 -12
- package/build/esm/utils/url.utils.d.ts +0 -1
- package/build/esm/utils/url.utils.js +49 -127
- package/build/esm/utils/validate.utils.d.ts +0 -1
- package/build/esm/utils/validate.utils.js +23 -40
- package/package.json +288 -63
- package/build/esm/config.js.map +0 -1
- package/build/esm/index.js.map +0 -1
- package/build/esm/servers/server.builder.js.map +0 -1
- package/build/esm/servers/server.js.map +0 -1
- package/build/esm/types/api-response.js.map +0 -1
- package/build/esm/types/index.js.map +0 -1
- package/build/esm/types/server.js.map +0 -1
- package/build/esm/utils/array.utils.js.map +0 -1
- package/build/esm/utils/async.utils.js.map +0 -1
- package/build/esm/utils/cache.utils.js.map +0 -1
- package/build/esm/utils/context-store.utils.js.map +0 -1
- package/build/esm/utils/crypto.utils.js.map +0 -1
- package/build/esm/utils/date.utils.js.map +0 -1
- package/build/esm/utils/decorators.utils.js.map +0 -1
- package/build/esm/utils/dir.utils.js.map +0 -1
- package/build/esm/utils/env.utils.js.map +0 -1
- package/build/esm/utils/exception.utils.js.map +0 -1
- package/build/esm/utils/fs.utils.js.map +0 -1
- package/build/esm/utils/http-status-codes.js.map +0 -1
- package/build/esm/utils/id.utils.js.map +0 -1
- package/build/esm/utils/logger.utils.js.map +0 -1
- package/build/esm/utils/middleware.utils.js.map +0 -1
- package/build/esm/utils/obj.utils.js.map +0 -1
- package/build/esm/utils/performance.utils.js.map +0 -1
- package/build/esm/utils/request.utils.js.map +0 -1
- package/build/esm/utils/response.utils.js.map +0 -1
- package/build/esm/utils/stream.utils.js.map +0 -1
- package/build/esm/utils/string.utils.js.map +0 -1
- package/build/esm/utils/type.utils.js.map +0 -1
- package/build/esm/utils/url.utils.js.map +0 -1
- package/build/esm/utils/validate.utils.js.map +0 -1
- package/build/esnext/config.js +0 -133
- package/build/esnext/config.js.map +0 -1
- package/build/esnext/index.js +0 -50
- package/build/esnext/index.js.map +0 -1
- package/build/esnext/servers/server.builder.js +0 -657
- package/build/esnext/servers/server.builder.js.map +0 -1
- package/build/esnext/servers/server.d.ts +0 -256
- package/build/esnext/servers/server.js +0 -955
- package/build/esnext/servers/server.js.map +0 -1
- package/build/esnext/types/api-response.d.ts +0 -152
- package/build/esnext/types/api-response.js +0 -34
- package/build/esnext/types/api-response.js.map +0 -1
- package/build/esnext/types/index.d.ts +0 -125
- package/build/esnext/types/index.js +0 -25
- package/build/esnext/types/index.js.map +0 -1
- package/build/esnext/types/server.d.ts +0 -268
- package/build/esnext/types/server.js +0 -25
- package/build/esnext/types/server.js.map +0 -1
- package/build/esnext/utils/array.utils.d.ts +0 -168
- package/build/esnext/utils/array.utils.js +0 -345
- package/build/esnext/utils/array.utils.js.map +0 -1
- package/build/esnext/utils/async.utils.d.ts +0 -265
- package/build/esnext/utils/async.utils.js +0 -620
- package/build/esnext/utils/async.utils.js.map +0 -1
- package/build/esnext/utils/cache.utils.js +0 -293
- package/build/esnext/utils/cache.utils.js.map +0 -1
- package/build/esnext/utils/context-store.utils.js +0 -289
- package/build/esnext/utils/context-store.utils.js.map +0 -1
- package/build/esnext/utils/crypto.utils.js +0 -276
- package/build/esnext/utils/crypto.utils.js.map +0 -1
- package/build/esnext/utils/date.utils.d.ts +0 -159
- package/build/esnext/utils/date.utils.js +0 -384
- package/build/esnext/utils/date.utils.js.map +0 -1
- package/build/esnext/utils/decorators.utils.d.ts +0 -508
- package/build/esnext/utils/decorators.utils.js +0 -877
- package/build/esnext/utils/decorators.utils.js.map +0 -1
- package/build/esnext/utils/dir.utils.js +0 -477
- package/build/esnext/utils/dir.utils.js.map +0 -1
- package/build/esnext/utils/env.utils.js +0 -785
- package/build/esnext/utils/env.utils.js.map +0 -1
- package/build/esnext/utils/exception.utils.d.ts +0 -230
- package/build/esnext/utils/exception.utils.js +0 -381
- package/build/esnext/utils/exception.utils.js.map +0 -1
- package/build/esnext/utils/fs.utils.d.ts +0 -164
- package/build/esnext/utils/fs.utils.js +0 -349
- package/build/esnext/utils/fs.utils.js.map +0 -1
- package/build/esnext/utils/http-status-codes.js +0 -295
- package/build/esnext/utils/http-status-codes.js.map +0 -1
- package/build/esnext/utils/id.utils.js +0 -84
- package/build/esnext/utils/id.utils.js.map +0 -1
- package/build/esnext/utils/logger.utils.d.ts +0 -160
- package/build/esnext/utils/logger.utils.js +0 -300
- package/build/esnext/utils/logger.utils.js.map +0 -1
- package/build/esnext/utils/middleware.utils.js +0 -236
- package/build/esnext/utils/middleware.utils.js.map +0 -1
- package/build/esnext/utils/obj.utils.js +0 -413
- package/build/esnext/utils/obj.utils.js.map +0 -1
- package/build/esnext/utils/performance.utils.d.ts +0 -136
- package/build/esnext/utils/performance.utils.js +0 -271
- package/build/esnext/utils/performance.utils.js.map +0 -1
- package/build/esnext/utils/request.utils.js +0 -186
- package/build/esnext/utils/request.utils.js.map +0 -1
- package/build/esnext/utils/response.utils.js +0 -247
- package/build/esnext/utils/response.utils.js.map +0 -1
- package/build/esnext/utils/stream.utils.js +0 -210
- package/build/esnext/utils/stream.utils.js.map +0 -1
- package/build/esnext/utils/string.utils.js +0 -165
- package/build/esnext/utils/string.utils.js.map +0 -1
- package/build/esnext/utils/type.utils.d.ts +0 -90
- package/build/esnext/utils/type.utils.js +0 -187
- package/build/esnext/utils/type.utils.js.map +0 -1
- package/build/esnext/utils/url.utils.d.ts +0 -141
- package/build/esnext/utils/url.utils.js +0 -304
- package/build/esnext/utils/url.utils.js.map +0 -1
- package/build/esnext/utils/validate.utils.d.ts +0 -177
- package/build/esnext/utils/validate.utils.js +0 -320
- package/build/esnext/utils/validate.utils.js.map +0 -1
- package/build/src/config.d.ts +0 -122
- package/build/src/config.js.map +0 -1
- package/build/src/index.d.ts +0 -27
- package/build/src/index.js.map +0 -1
- package/build/src/servers/server.builder.d.ts +0 -508
- package/build/src/servers/server.builder.js.map +0 -1
- package/build/src/servers/server.js.map +0 -1
- package/build/src/types/api-response.js.map +0 -1
- package/build/src/types/index.js.map +0 -1
- package/build/src/types/server.js.map +0 -1
- package/build/src/utils/array.utils.js.map +0 -1
- package/build/src/utils/async.utils.js.map +0 -1
- package/build/src/utils/cache.utils.d.ts +0 -153
- package/build/src/utils/cache.utils.js.map +0 -1
- package/build/src/utils/context-store.utils.d.ts +0 -189
- package/build/src/utils/context-store.utils.js.map +0 -1
- package/build/src/utils/crypto.utils.d.ts +0 -160
- package/build/src/utils/crypto.utils.js.map +0 -1
- package/build/src/utils/date.utils.js.map +0 -1
- package/build/src/utils/decorators.utils.js.map +0 -1
- package/build/src/utils/dir.utils.d.ts +0 -196
- package/build/src/utils/dir.utils.js.map +0 -1
- package/build/src/utils/env.utils.d.ts +0 -377
- package/build/src/utils/env.utils.js.map +0 -1
- package/build/src/utils/exception.utils.js.map +0 -1
- package/build/src/utils/fs.utils.js.map +0 -1
- package/build/src/utils/http-status-codes.d.ts +0 -266
- package/build/src/utils/http-status-codes.js.map +0 -1
- package/build/src/utils/id.utils.d.ts +0 -36
- package/build/src/utils/id.utils.js.map +0 -1
- package/build/src/utils/logger.utils.js.map +0 -1
- package/build/src/utils/middleware.utils.d.ts +0 -100
- package/build/src/utils/middleware.utils.js.map +0 -1
- package/build/src/utils/obj.utils.d.ts +0 -124
- package/build/src/utils/obj.utils.js.map +0 -1
- package/build/src/utils/performance.utils.js.map +0 -1
- package/build/src/utils/request.utils.d.ts +0 -86
- package/build/src/utils/request.utils.js.map +0 -1
- package/build/src/utils/response.utils.d.ts +0 -163
- package/build/src/utils/response.utils.js.map +0 -1
- package/build/src/utils/stream.utils.d.ts +0 -88
- package/build/src/utils/stream.utils.js.map +0 -1
- package/build/src/utils/string.utils.d.ts +0 -93
- package/build/src/utils/string.utils.js.map +0 -1
- package/build/src/utils/type.utils.js.map +0 -1
- package/build/src/utils/url.utils.js.map +0 -1
- package/build/src/utils/validate.utils.js.map +0 -1
|
@@ -76,6 +76,11 @@ function getFromContext(key) {
|
|
|
76
76
|
* ```
|
|
77
77
|
*/
|
|
78
78
|
class ContextStore {
|
|
79
|
+
/**
|
|
80
|
+
* The underlying AsyncLocalStorage instance for context.
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
static storage = new async_hooks_1.AsyncLocalStorage();
|
|
79
84
|
/**
|
|
80
85
|
* Returns the raw AsyncLocalStorage instance for advanced access.
|
|
81
86
|
*
|
|
@@ -93,7 +98,7 @@ class ContextStore {
|
|
|
93
98
|
*/
|
|
94
99
|
static get(key) {
|
|
95
100
|
const store = this.storage.getStore();
|
|
96
|
-
return store
|
|
101
|
+
return store?.[key];
|
|
97
102
|
}
|
|
98
103
|
/**
|
|
99
104
|
* Sets a value in the current context store by symbol key.
|
|
@@ -215,7 +220,7 @@ class ContextStore {
|
|
|
215
220
|
static extend(newValues, callback) {
|
|
216
221
|
const currentStore = this.storage.getStore() || {};
|
|
217
222
|
// Create new store with current values plus new ones
|
|
218
|
-
const newStore =
|
|
223
|
+
const newStore = { ...currentStore };
|
|
219
224
|
// Add new values
|
|
220
225
|
Object.getOwnPropertySymbols(newValues).forEach(key => {
|
|
221
226
|
newStore[key] = newValues[key];
|
|
@@ -230,24 +235,21 @@ class ContextStore {
|
|
|
230
235
|
* @returns Express middleware function.
|
|
231
236
|
*/
|
|
232
237
|
static createExpressMiddleware(initialValuesFactory = () => ({})) {
|
|
233
|
-
return (req,
|
|
238
|
+
return (req, _res, next) => {
|
|
234
239
|
const initialValues = initialValuesFactory(req);
|
|
235
240
|
ContextStore.run(initialValues, next);
|
|
236
241
|
};
|
|
237
242
|
}
|
|
238
243
|
}
|
|
239
244
|
exports.ContextStore = ContextStore;
|
|
240
|
-
/**
|
|
241
|
-
* The underlying AsyncLocalStorage instance for context.
|
|
242
|
-
* @private
|
|
243
|
-
*/
|
|
244
|
-
ContextStore.storage = new async_hooks_1.AsyncLocalStorage();
|
|
245
245
|
/**
|
|
246
246
|
* Type-safe wrapper for accessing and modifying context values with specific types.
|
|
247
247
|
*
|
|
248
248
|
* @typeParam T - The value type.
|
|
249
249
|
*/
|
|
250
250
|
class TypedContextKey {
|
|
251
|
+
symbol;
|
|
252
|
+
defaultValue;
|
|
251
253
|
/**
|
|
252
254
|
* Creates a new typed context key.
|
|
253
255
|
*
|
|
@@ -293,4 +295,3 @@ class TypedContextKey {
|
|
|
293
295
|
}
|
|
294
296
|
}
|
|
295
297
|
exports.TypedContextKey = TypedContextKey;
|
|
296
|
-
//# sourceMappingURL=context-store.utils.js.map
|
|
@@ -157,4 +157,3 @@ export declare function createSignedToken(payload: Record<string, any>, secret:
|
|
|
157
157
|
* @returns {object | null} Decoded payload if valid, null if invalid
|
|
158
158
|
*/
|
|
159
159
|
export declare function verifySignedToken(token: string, secret: string): Record<string, any> | null;
|
|
160
|
-
//# sourceMappingURL=crypto.utils.d.ts.map
|
|
@@ -250,7 +250,10 @@ async function decrypt(encryptedData, key, options = {}) {
|
|
|
250
250
|
*/
|
|
251
251
|
function createSignedToken(payload, secret, expiresInSeconds = 3600) {
|
|
252
252
|
// Create payload with expiration
|
|
253
|
-
const tokenPayload =
|
|
253
|
+
const tokenPayload = {
|
|
254
|
+
...payload,
|
|
255
|
+
exp: Math.floor(Date.now() / 1000) + expiresInSeconds
|
|
256
|
+
};
|
|
254
257
|
// Convert to string
|
|
255
258
|
const payloadStr = JSON.stringify(tokenPayload);
|
|
256
259
|
// Base64 encode the payload
|
|
@@ -286,8 +289,7 @@ function verifySignedToken(token, secret) {
|
|
|
286
289
|
}
|
|
287
290
|
return payload;
|
|
288
291
|
}
|
|
289
|
-
catch
|
|
292
|
+
catch {
|
|
290
293
|
return null;
|
|
291
294
|
}
|
|
292
295
|
}
|
|
293
|
-
//# sourceMappingURL=crypto.utils.js.map
|
|
@@ -142,7 +142,7 @@ function parseDate(input, fallback) {
|
|
|
142
142
|
}
|
|
143
143
|
return date;
|
|
144
144
|
}
|
|
145
|
-
catch
|
|
145
|
+
catch {
|
|
146
146
|
return fallback || null;
|
|
147
147
|
}
|
|
148
148
|
}
|
|
@@ -393,4 +393,3 @@ function daysInMonth(year, month) {
|
|
|
393
393
|
}
|
|
394
394
|
return new Date(year, month + 1, 0).getDate();
|
|
395
395
|
}
|
|
396
|
-
//# sourceMappingURL=date.utils.js.map
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import type { RequestHandler, Router } from 'express';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
constructor(maxSize?: number, ttlMs?: number);
|
|
10
|
-
private generateKey;
|
|
11
|
-
get(options: {
|
|
12
|
-
max: number;
|
|
13
|
-
windowMs: number;
|
|
14
|
-
standardHeaders: boolean;
|
|
15
|
-
legacyHeaders: boolean;
|
|
16
|
-
}): ReturnType<typeof rateLimit>;
|
|
3
|
+
type Constructor<T = any> = new (...args: any[]) => T;
|
|
4
|
+
export declare class DIContainer {
|
|
5
|
+
private instances;
|
|
6
|
+
private constructing;
|
|
7
|
+
register<T>(target: Constructor<T>): void;
|
|
8
|
+
get<T>(target: Constructor<T>): T;
|
|
17
9
|
clear(): void;
|
|
18
|
-
size(): number;
|
|
19
|
-
destroy(): void;
|
|
20
10
|
}
|
|
21
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Injectable decorator for marking classes as injectable.
|
|
13
|
+
*
|
|
14
|
+
* @returns Class decorator that marks a class as injectable and registers it with the DI container.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Injectable(): ClassDecorator;
|
|
17
|
+
/**
|
|
18
|
+
* Inject decorator for injecting dependencies into class properties.
|
|
19
|
+
*
|
|
20
|
+
* @param targetClass - The class to inject
|
|
21
|
+
* @returns Property decorator that injects the specified class into the property
|
|
22
|
+
*/
|
|
23
|
+
export declare function Inject<T>(targetClass: new (...args: any[]) => T): PropertyDecorator;
|
|
22
24
|
/**
|
|
23
25
|
* Decorator for GET HTTP method routes.
|
|
24
26
|
*
|
|
@@ -244,7 +246,7 @@ export declare function HttpCode(status: number): MethodDecorator;
|
|
|
244
246
|
* return { data: '...' };
|
|
245
247
|
* }
|
|
246
248
|
*/
|
|
247
|
-
export declare function Header(name: string, value: string): MethodDecorator;
|
|
249
|
+
export declare function Header(name: string, value: string): MethodDecorator & ClassDecorator;
|
|
248
250
|
/**
|
|
249
251
|
* Decorator that adds a custom HTTP headers to the response.
|
|
250
252
|
*
|
|
@@ -274,7 +276,7 @@ export declare function Header(name: string, value: string): MethodDecorator;
|
|
|
274
276
|
*
|
|
275
277
|
* ```
|
|
276
278
|
*/
|
|
277
|
-
export declare function Headers(headers: Record<string, string> | string, value?: string): MethodDecorator;
|
|
279
|
+
export declare function Headers(headers: Record<string, string> | string, value?: string): MethodDecorator & ClassDecorator;
|
|
278
280
|
/**
|
|
279
281
|
* Decorator that registers a function to run before route handler execution.
|
|
280
282
|
* Useful for pre-processing or logging.
|
|
@@ -314,6 +316,8 @@ export declare function After(fn: Function): MethodDecorator;
|
|
|
314
316
|
* Decorator that requires specific roles for accessing a route.
|
|
315
317
|
* Must be used with authentication middleware.
|
|
316
318
|
*
|
|
319
|
+
* Check req.user.roles for user roles[].
|
|
320
|
+
*
|
|
317
321
|
* @param roles - List of roles that can access this route
|
|
318
322
|
* @returns Method decorator
|
|
319
323
|
*
|
|
@@ -327,7 +331,7 @@ export declare function After(fn: Function): MethodDecorator;
|
|
|
327
331
|
* }
|
|
328
332
|
* ```
|
|
329
333
|
*/
|
|
330
|
-
export declare function Roles(...roles: string[]): MethodDecorator;
|
|
334
|
+
export declare function Roles(...roles: string[]): MethodDecorator & ClassDecorator;
|
|
331
335
|
/**
|
|
332
336
|
* Decorator that redirects to another URL.
|
|
333
337
|
*
|
|
@@ -367,7 +371,7 @@ export declare function Redirect(url?: string, statusCode?: number): MethodDecor
|
|
|
367
371
|
* }
|
|
368
372
|
* ```
|
|
369
373
|
*/
|
|
370
|
-
export declare function Cache(ttlSeconds: number): MethodDecorator;
|
|
374
|
+
export declare function Cache(ttlSeconds: number): MethodDecorator & ClassDecorator;
|
|
371
375
|
/**
|
|
372
376
|
* Decorator that applies rate limiting to a route.
|
|
373
377
|
* Note: Requires 'express-rate-limit' package to be installed.
|
|
@@ -394,7 +398,7 @@ export declare function RateLimit(options: {
|
|
|
394
398
|
windowMs: number;
|
|
395
399
|
standardHeaders?: boolean;
|
|
396
400
|
legacyHeaders?: boolean;
|
|
397
|
-
}): MethodDecorator;
|
|
401
|
+
}): MethodDecorator & ClassDecorator;
|
|
398
402
|
/**
|
|
399
403
|
* Decorator that sets the content type for the response.
|
|
400
404
|
*
|
|
@@ -444,7 +448,7 @@ export declare function Version(version: string, options?: {
|
|
|
444
448
|
addPrefix?: boolean;
|
|
445
449
|
addHeader?: boolean;
|
|
446
450
|
headerName?: string;
|
|
447
|
-
}): MethodDecorator;
|
|
451
|
+
}): MethodDecorator & ClassDecorator;
|
|
448
452
|
/**
|
|
449
453
|
* Decorator that sets a timeout for route execution.
|
|
450
454
|
*
|
|
@@ -460,7 +464,7 @@ export declare function Version(version: string, options?: {
|
|
|
460
464
|
* }
|
|
461
465
|
* ```
|
|
462
466
|
*/
|
|
463
|
-
export declare function Timeout(ms: number): MethodDecorator;
|
|
467
|
+
export declare function Timeout(ms: number): MethodDecorator & ClassDecorator;
|
|
464
468
|
/**
|
|
465
469
|
* Decorator that adds comprehensive logging to a route.
|
|
466
470
|
*
|
|
@@ -495,7 +499,7 @@ export declare function Log(options?: {
|
|
|
495
499
|
logBody?: boolean;
|
|
496
500
|
logParams?: boolean;
|
|
497
501
|
logResponse?: boolean;
|
|
498
|
-
}): MethodDecorator;
|
|
502
|
+
}): MethodDecorator & ClassDecorator;
|
|
499
503
|
/**
|
|
500
504
|
* Registers all controller classes with the provided router.
|
|
501
505
|
* This function processes all decorators and sets up the Express routes.
|
|
@@ -504,5 +508,4 @@ export declare function Log(options?: {
|
|
|
504
508
|
* @param controllers - Array of controller classes
|
|
505
509
|
*/
|
|
506
510
|
export declare function registerControllers(router: Router, controllers: any[]): void;
|
|
507
|
-
export {
|
|
508
|
-
//# sourceMappingURL=decorators.utils.d.ts.map
|
|
511
|
+
export {};
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.Res = exports.Req = exports.Body = exports.Param = exports.Query = exports.Connect = exports.Trace = exports.Head = exports.Options = exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = exports.DIContainer = void 0;
|
|
27
|
+
exports.Injectable = Injectable;
|
|
28
|
+
exports.Inject = Inject;
|
|
27
29
|
exports.Controller = Controller;
|
|
28
30
|
exports.Use = Use;
|
|
29
31
|
exports.HttpCode = HttpCode;
|
|
@@ -66,6 +68,7 @@ const LOG_KEY = Symbol('log');
|
|
|
66
68
|
* RateLimiter cache that uses TTLCache for automatic TTL and LRU handling.
|
|
67
69
|
*/
|
|
68
70
|
class RateLimiterCache {
|
|
71
|
+
cache;
|
|
69
72
|
constructor(maxSize = 100, ttlMs = 5 * 60 * 1000) {
|
|
70
73
|
this.cache = new cache_utils_1.TTLCache({
|
|
71
74
|
maxSize,
|
|
@@ -82,10 +85,13 @@ class RateLimiterCache {
|
|
|
82
85
|
return cached.limiter;
|
|
83
86
|
}
|
|
84
87
|
// Create new limiter
|
|
85
|
-
const limiter = (0, express_rate_limit_1.rateLimit)(
|
|
88
|
+
const limiter = (0, express_rate_limit_1.rateLimit)({
|
|
89
|
+
...options,
|
|
90
|
+
handler: (req, res) => {
|
|
86
91
|
const errorResponse = (0, response_utils_1.createFinalErrorResponse)(req, http_status_codes_1.HttpStatusCodes.TOO_MANY_REQUESTS, 'Too Many Requests');
|
|
87
92
|
res.status(http_status_codes_1.HttpStatusCodes.TOO_MANY_REQUESTS).json(errorResponse);
|
|
88
|
-
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
89
95
|
// Store in cache
|
|
90
96
|
this.cache.set(key, {
|
|
91
97
|
limiter,
|
|
@@ -103,10 +109,49 @@ class RateLimiterCache {
|
|
|
103
109
|
this.cache.destroy();
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
|
-
exports.RateLimiterCache = RateLimiterCache;
|
|
107
112
|
// Global cache instance
|
|
108
113
|
const rateLimiterCache = new RateLimiterCache();
|
|
109
|
-
|
|
114
|
+
class DIContainer {
|
|
115
|
+
instances = new Map();
|
|
116
|
+
constructing = new Map();
|
|
117
|
+
register(target) {
|
|
118
|
+
// Mark as injectable, but do not instantiate yet
|
|
119
|
+
if (!this.instances.has(target) && !this.constructing.has(target)) {
|
|
120
|
+
// No-op: instantiation is deferred until get()
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
get(target) {
|
|
124
|
+
// Return existing instance if available
|
|
125
|
+
if (this.instances.has(target)) {
|
|
126
|
+
return this.instances.get(target);
|
|
127
|
+
}
|
|
128
|
+
// If currently constructing, return the proxy (for circular refs)
|
|
129
|
+
if (this.constructing.has(target)) {
|
|
130
|
+
return this.constructing.get(target);
|
|
131
|
+
}
|
|
132
|
+
// Mark as constructing (for circular dependency support)
|
|
133
|
+
let proxy = {};
|
|
134
|
+
this.constructing.set(target, proxy);
|
|
135
|
+
// Resolve constructor dependencies
|
|
136
|
+
const paramTypes = Reflect.getMetadata('design:paramtypes', target) || [];
|
|
137
|
+
const dependencies = paramTypes.map(dep => this.get(dep));
|
|
138
|
+
const instance = new target(...dependencies);
|
|
139
|
+
// Copy instance properties to proxy (for circular refs)
|
|
140
|
+
Object.assign(proxy, instance);
|
|
141
|
+
// Replace proxy with real instance
|
|
142
|
+
this.instances.set(target, proxy);
|
|
143
|
+
this.constructing.delete(target);
|
|
144
|
+
// Copy prototype (for instanceof checks)
|
|
145
|
+
Object.setPrototypeOf(proxy, target.prototype);
|
|
146
|
+
return proxy;
|
|
147
|
+
}
|
|
148
|
+
clear() {
|
|
149
|
+
this.instances.clear();
|
|
150
|
+
this.constructing.clear();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.DIContainer = DIContainer;
|
|
154
|
+
const diContainer = new DIContainer();
|
|
110
155
|
function normalizeHeaderValue(value) {
|
|
111
156
|
if (typeof value === 'undefined')
|
|
112
157
|
return undefined;
|
|
@@ -117,6 +162,34 @@ function normalizeHeaderValue(value) {
|
|
|
117
162
|
}
|
|
118
163
|
return String(value);
|
|
119
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Injectable decorator for marking classes as injectable.
|
|
167
|
+
*
|
|
168
|
+
* @returns Class decorator that marks a class as injectable and registers it with the DI container.
|
|
169
|
+
*/
|
|
170
|
+
function Injectable() {
|
|
171
|
+
return target => {
|
|
172
|
+
Reflect.defineMetadata('injectable', true, target);
|
|
173
|
+
diContainer.register(target);
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Inject decorator for injecting dependencies into class properties.
|
|
178
|
+
*
|
|
179
|
+
* @param targetClass - The class to inject
|
|
180
|
+
* @returns Property decorator that injects the specified class into the property
|
|
181
|
+
*/
|
|
182
|
+
function Inject(targetClass) {
|
|
183
|
+
return (target, propertyKey) => {
|
|
184
|
+
Object.defineProperty(target, propertyKey, {
|
|
185
|
+
get: function () {
|
|
186
|
+
return diContainer.get(targetClass);
|
|
187
|
+
},
|
|
188
|
+
enumerable: true,
|
|
189
|
+
configurable: true
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
}
|
|
120
193
|
/**
|
|
121
194
|
* Factory function that creates HTTP method decorators.
|
|
122
195
|
*
|
|
@@ -125,7 +198,7 @@ function normalizeHeaderValue(value) {
|
|
|
125
198
|
*/
|
|
126
199
|
function createRouteDecorator(method) {
|
|
127
200
|
return (path) => {
|
|
128
|
-
return (target, propertyKey,
|
|
201
|
+
return (target, propertyKey, _descriptor) => {
|
|
129
202
|
const routes = Reflect.getMetadata(ROUTES_KEY, target.constructor) || [];
|
|
130
203
|
routes.push({
|
|
131
204
|
path,
|
|
@@ -426,9 +499,18 @@ function Header(name, value) {
|
|
|
426
499
|
*/
|
|
427
500
|
function Headers(headers, value) {
|
|
428
501
|
return (target, propertyKey) => {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
502
|
+
if (typeof propertyKey === 'undefined') {
|
|
503
|
+
// Class decorator
|
|
504
|
+
const existing = Reflect.getMetadata(HEADER_KEY, target) || {};
|
|
505
|
+
const newHeaders = typeof headers === 'string' ? { [headers]: value } : headers;
|
|
506
|
+
Reflect.defineMetadata(HEADER_KEY, { ...existing, ...newHeaders }, target);
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
// Method decorator
|
|
510
|
+
const existing = Reflect.getMetadata(HEADER_KEY, target, propertyKey) || {};
|
|
511
|
+
const newHeaders = typeof headers === 'string' ? { [headers]: value } : headers;
|
|
512
|
+
Reflect.defineMetadata(HEADER_KEY, { ...existing, ...newHeaders }, target, propertyKey);
|
|
513
|
+
}
|
|
432
514
|
};
|
|
433
515
|
}
|
|
434
516
|
/**
|
|
@@ -482,6 +564,8 @@ function After(fn) {
|
|
|
482
564
|
* Decorator that requires specific roles for accessing a route.
|
|
483
565
|
* Must be used with authentication middleware.
|
|
484
566
|
*
|
|
567
|
+
* Check req.user.roles for user roles[].
|
|
568
|
+
*
|
|
485
569
|
* @param roles - List of roles that can access this route
|
|
486
570
|
* @returns Method decorator
|
|
487
571
|
*
|
|
@@ -497,7 +581,14 @@ function After(fn) {
|
|
|
497
581
|
*/
|
|
498
582
|
function Roles(...roles) {
|
|
499
583
|
return (target, propertyKey, _descriptor) => {
|
|
500
|
-
|
|
584
|
+
if (typeof propertyKey === 'undefined') {
|
|
585
|
+
// Class decorator
|
|
586
|
+
Reflect.defineMetadata(ROLES_KEY, roles, target);
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
// Method decorator
|
|
590
|
+
Reflect.defineMetadata(ROLES_KEY, roles, target, propertyKey);
|
|
591
|
+
}
|
|
501
592
|
};
|
|
502
593
|
}
|
|
503
594
|
/**
|
|
@@ -547,7 +638,14 @@ function Redirect(url, statusCode = 302) {
|
|
|
547
638
|
*/
|
|
548
639
|
function Cache(ttlSeconds) {
|
|
549
640
|
return (target, propertyKey, _descriptor) => {
|
|
550
|
-
|
|
641
|
+
if (typeof propertyKey === 'undefined') {
|
|
642
|
+
// Class decorator
|
|
643
|
+
Reflect.defineMetadata(CACHE_KEY, { ttlSeconds }, target);
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
// Method decorator
|
|
647
|
+
Reflect.defineMetadata(CACHE_KEY, { ttlSeconds }, target, propertyKey);
|
|
648
|
+
}
|
|
551
649
|
};
|
|
552
650
|
}
|
|
553
651
|
/**
|
|
@@ -572,9 +670,20 @@ function Cache(ttlSeconds) {
|
|
|
572
670
|
* ```
|
|
573
671
|
*/
|
|
574
672
|
function RateLimit(options) {
|
|
575
|
-
const opts =
|
|
673
|
+
const opts = {
|
|
674
|
+
standardHeaders: true,
|
|
675
|
+
legacyHeaders: false,
|
|
676
|
+
...options
|
|
677
|
+
};
|
|
576
678
|
return (target, propertyKey, _descriptor) => {
|
|
577
|
-
|
|
679
|
+
if (typeof propertyKey === 'undefined') {
|
|
680
|
+
// Class decorator
|
|
681
|
+
Reflect.defineMetadata(RATE_LIMIT_KEY, opts, target);
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
// Method decorator
|
|
685
|
+
Reflect.defineMetadata(RATE_LIMIT_KEY, opts, target, propertyKey);
|
|
686
|
+
}
|
|
578
687
|
};
|
|
579
688
|
}
|
|
580
689
|
/**
|
|
@@ -627,9 +736,21 @@ function ContentType(type) {
|
|
|
627
736
|
* ```
|
|
628
737
|
*/
|
|
629
738
|
function Version(version, options) {
|
|
630
|
-
const opts =
|
|
739
|
+
const opts = {
|
|
740
|
+
addPrefix: true,
|
|
741
|
+
addHeader: true,
|
|
742
|
+
headerName: 'X-API-Version',
|
|
743
|
+
...options
|
|
744
|
+
};
|
|
631
745
|
return (target, propertyKey, _descriptor) => {
|
|
632
|
-
|
|
746
|
+
if (typeof propertyKey === 'undefined') {
|
|
747
|
+
// Class decorator
|
|
748
|
+
Reflect.defineMetadata(VERSION_KEY, { version, options: opts }, target);
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
// Method decorator
|
|
752
|
+
Reflect.defineMetadata(VERSION_KEY, { version, options: opts }, target, propertyKey);
|
|
753
|
+
}
|
|
633
754
|
};
|
|
634
755
|
}
|
|
635
756
|
/**
|
|
@@ -649,7 +770,14 @@ function Version(version, options) {
|
|
|
649
770
|
*/
|
|
650
771
|
function Timeout(ms) {
|
|
651
772
|
return (target, propertyKey, _descriptor) => {
|
|
652
|
-
|
|
773
|
+
if (typeof propertyKey === 'undefined') {
|
|
774
|
+
// Class decorator
|
|
775
|
+
Reflect.defineMetadata(TIMEOUT_KEY, { ms }, target);
|
|
776
|
+
}
|
|
777
|
+
else {
|
|
778
|
+
// Method decorator
|
|
779
|
+
Reflect.defineMetadata(TIMEOUT_KEY, { ms }, target, propertyKey);
|
|
780
|
+
}
|
|
653
781
|
};
|
|
654
782
|
}
|
|
655
783
|
/**
|
|
@@ -682,8 +810,22 @@ function Timeout(ms) {
|
|
|
682
810
|
*/
|
|
683
811
|
function Log(options) {
|
|
684
812
|
return (target, propertyKey, _descriptor) => {
|
|
685
|
-
const config =
|
|
686
|
-
|
|
813
|
+
const config = {
|
|
814
|
+
logEntry: true,
|
|
815
|
+
logExit: true,
|
|
816
|
+
logBody: false,
|
|
817
|
+
logParams: false,
|
|
818
|
+
logResponse: false,
|
|
819
|
+
...options
|
|
820
|
+
};
|
|
821
|
+
if (typeof propertyKey === 'undefined') {
|
|
822
|
+
// Class decorator
|
|
823
|
+
Reflect.defineMetadata(LOG_KEY, config, target);
|
|
824
|
+
}
|
|
825
|
+
else {
|
|
826
|
+
// Method decorator
|
|
827
|
+
Reflect.defineMetadata(LOG_KEY, config, target, propertyKey);
|
|
828
|
+
}
|
|
687
829
|
};
|
|
688
830
|
}
|
|
689
831
|
/**
|
|
@@ -695,7 +837,8 @@ function Log(options) {
|
|
|
695
837
|
*/
|
|
696
838
|
function registerControllers(router, controllers) {
|
|
697
839
|
controllers.forEach(ControllerClass => {
|
|
698
|
-
|
|
840
|
+
// Use DI container to resolve controller (constructor injection + property injection)
|
|
841
|
+
const instance = diContainer.get(ControllerClass);
|
|
699
842
|
const basePath = Reflect.getMetadata('basePath', ControllerClass) || '';
|
|
700
843
|
const routes = Reflect.getMetadata(ROUTES_KEY, ControllerClass) || [];
|
|
701
844
|
// Get controller-level decorators (fallback values)
|
|
@@ -707,13 +850,12 @@ function registerControllers(router, controllers) {
|
|
|
707
850
|
const controllerLogConfig = Reflect.getMetadata(LOG_KEY, ControllerClass);
|
|
708
851
|
const controllerHeaders = Reflect.getMetadata(HEADER_KEY, ControllerClass) || {};
|
|
709
852
|
routes.forEach(({ path, method, handlerName }) => {
|
|
710
|
-
var _a;
|
|
711
853
|
const middlewares = Reflect.getMetadata(MIDDLEWARE_KEY, instance, handlerName) || [];
|
|
712
854
|
const params = Reflect.getMetadata(PARAMS_KEY, instance, handlerName) || [];
|
|
713
855
|
const httpCode = Reflect.getMetadata(HTTP_CODE_KEY, instance, handlerName);
|
|
714
856
|
// Merge controller-level and method-level headers
|
|
715
857
|
const methodHeaders = Reflect.getMetadata(HEADER_KEY, instance, handlerName) || {};
|
|
716
|
-
const headers =
|
|
858
|
+
const headers = { ...controllerHeaders, ...methodHeaders };
|
|
717
859
|
const beforeHooks = Reflect.getMetadata(BEFORE_KEY, instance, handlerName) || [];
|
|
718
860
|
const afterHooks = Reflect.getMetadata(AFTER_KEY, instance, handlerName) || [];
|
|
719
861
|
const redirect = Reflect.getMetadata(REDIRECT_KEY, instance, handlerName);
|
|
@@ -736,11 +878,10 @@ function registerControllers(router, controllers) {
|
|
|
736
878
|
}
|
|
737
879
|
}
|
|
738
880
|
let finalPath = path;
|
|
739
|
-
if (
|
|
881
|
+
if (version?.options?.addPrefix) {
|
|
740
882
|
finalPath = `/${version.version}${path}`;
|
|
741
883
|
}
|
|
742
884
|
const handler = async (req, res, next) => {
|
|
743
|
-
var _a, _b, _c, _d;
|
|
744
885
|
// Set start time for duration tracking
|
|
745
886
|
req['startTime'] = Date.now();
|
|
746
887
|
let timeoutId;
|
|
@@ -774,7 +915,7 @@ function registerControllers(router, controllers) {
|
|
|
774
915
|
res.setHeader('Content-Type', contentType.type);
|
|
775
916
|
}
|
|
776
917
|
// Handle versioning header
|
|
777
|
-
if (
|
|
918
|
+
if (version?.options?.addHeader && version?.options?.headerName && version?.version) {
|
|
778
919
|
if (!res.headersSent) {
|
|
779
920
|
res.setHeader(version.options.headerName, version.version);
|
|
780
921
|
}
|
|
@@ -784,7 +925,7 @@ function registerControllers(router, controllers) {
|
|
|
784
925
|
res.setHeader('Cache-Control', `public, max-age=${cache.ttlSeconds}`);
|
|
785
926
|
}
|
|
786
927
|
// Handle logging - entry
|
|
787
|
-
if (logConfig
|
|
928
|
+
if (logConfig?.logEntry) {
|
|
788
929
|
const logger = (0, logger_utils_1.getLogger)();
|
|
789
930
|
const logData = {
|
|
790
931
|
method: req.method,
|
|
@@ -800,7 +941,7 @@ function registerControllers(router, controllers) {
|
|
|
800
941
|
logger.info({ entry: logData }, 'Route Entry:');
|
|
801
942
|
}
|
|
802
943
|
// Handle roles-based access control
|
|
803
|
-
if (roles.length && !
|
|
944
|
+
if (roles.length && !req?.user?.roles?.some((role) => roles.includes(role))) {
|
|
804
945
|
const errorResponse = (0, response_utils_1.createFinalErrorResponse)(req, http_status_codes_1.HttpStatusCodes.FORBIDDEN, 'Forbidden Insufficient Roles');
|
|
805
946
|
res.status(http_status_codes_1.HttpStatusCodes.FORBIDDEN).json(errorResponse);
|
|
806
947
|
if (timeoutId) {
|
|
@@ -820,7 +961,6 @@ function registerControllers(router, controllers) {
|
|
|
820
961
|
const args = [];
|
|
821
962
|
if (params.length) {
|
|
822
963
|
params.forEach(({ index, type, key }) => {
|
|
823
|
-
var _a;
|
|
824
964
|
switch (type) {
|
|
825
965
|
case 'query':
|
|
826
966
|
args[index] = key ? req.query[key] : req.query;
|
|
@@ -829,7 +969,7 @@ function registerControllers(router, controllers) {
|
|
|
829
969
|
args[index] = key ? req.params[key] : req.params;
|
|
830
970
|
break;
|
|
831
971
|
case 'body':
|
|
832
|
-
args[index] = key ?
|
|
972
|
+
args[index] = key ? req.body?.[key] : req.body;
|
|
833
973
|
break;
|
|
834
974
|
case 'req':
|
|
835
975
|
args[index] = req;
|
|
@@ -867,7 +1007,7 @@ function registerControllers(router, controllers) {
|
|
|
867
1007
|
res.json(awaited);
|
|
868
1008
|
}
|
|
869
1009
|
// Handle logging - exit
|
|
870
|
-
if (logConfig
|
|
1010
|
+
if (logConfig?.logExit) {
|
|
871
1011
|
const logger = (0, logger_utils_1.getLogger)();
|
|
872
1012
|
const logData = {
|
|
873
1013
|
method: req.method,
|
|
@@ -893,4 +1033,3 @@ function registerControllers(router, controllers) {
|
|
|
893
1033
|
});
|
|
894
1034
|
});
|
|
895
1035
|
}
|
|
896
|
-
//# sourceMappingURL=decorators.utils.js.map
|
|
@@ -105,7 +105,7 @@ async function isDirectory(pathStr) {
|
|
|
105
105
|
const stat = await promises_1.default.stat(pathStr);
|
|
106
106
|
return stat.isDirectory();
|
|
107
107
|
}
|
|
108
|
-
catch
|
|
108
|
+
catch {
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -209,7 +209,7 @@ function watchDir(dirPath, callback) {
|
|
|
209
209
|
* @throws {Error} If pattern matching fails.
|
|
210
210
|
*/
|
|
211
211
|
async function findFilesByPattern(pattern, options = {}) {
|
|
212
|
-
const defaultOptions =
|
|
212
|
+
const defaultOptions = { nodir: true, ...options };
|
|
213
213
|
return (0, glob_1.glob)(pattern, defaultOptions);
|
|
214
214
|
}
|
|
215
215
|
/**
|
|
@@ -273,7 +273,7 @@ async function createTempDir(options = {}) {
|
|
|
273
273
|
try {
|
|
274
274
|
await deleteDirRecursive(tempDirPath);
|
|
275
275
|
}
|
|
276
|
-
catch
|
|
276
|
+
catch {
|
|
277
277
|
// Ignore cleanup errors
|
|
278
278
|
}
|
|
279
279
|
};
|
|
@@ -282,7 +282,7 @@ async function createTempDir(options = {}) {
|
|
|
282
282
|
try {
|
|
283
283
|
fs_1.default.rmSync(tempDirPath, { recursive: true, force: true });
|
|
284
284
|
}
|
|
285
|
-
catch
|
|
285
|
+
catch {
|
|
286
286
|
// Ignore cleanup errors on exit
|
|
287
287
|
}
|
|
288
288
|
});
|
|
@@ -388,7 +388,7 @@ async function watchDirRecursive(dirPath, callback, includeSubdirs = true) {
|
|
|
388
388
|
addWatcher(fullPath);
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
-
catch
|
|
391
|
+
catch {
|
|
392
392
|
// Ignore errors checking newly created items
|
|
393
393
|
}
|
|
394
394
|
}, 100);
|
|
@@ -396,7 +396,7 @@ async function watchDirRecursive(dirPath, callback, includeSubdirs = true) {
|
|
|
396
396
|
});
|
|
397
397
|
watchers.push(watcher);
|
|
398
398
|
}
|
|
399
|
-
catch
|
|
399
|
+
catch {
|
|
400
400
|
// Silently ignore directories we can't watch
|
|
401
401
|
}
|
|
402
402
|
};
|
|
@@ -498,4 +498,3 @@ async function walkDir(dirPath, options) {
|
|
|
498
498
|
await options.visitorFn(entryInfo);
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
|
-
//# sourceMappingURL=dir.utils.js.map
|