@catbee/utils 0.0.8-rc.4 → 1.0.2
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/README.md +3 -2
- package/build/index.cjs +2078 -1108
- package/build/index.d.ts +648 -23
- package/build/index.mjs +2044 -1109
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { AsyncLocalStorage } from 'async_hooks';
|
|
|
26
26
|
import { BinaryToTextEncoding, CipherGCMTypes } from 'crypto';
|
|
27
27
|
import express, { RequestHandler, Router, Request, Response, NextFunction, Express, json, urlencoded } from 'express';
|
|
28
28
|
import fs, { Stats } from 'fs';
|
|
29
|
+
import { Readable, Transform } from 'stream';
|
|
29
30
|
import * as prom_client from 'prom-client';
|
|
30
31
|
import http from 'http';
|
|
31
32
|
import https from 'https';
|
|
@@ -37,7 +38,7 @@ import { CorsOptions } from 'cors';
|
|
|
37
38
|
/**
|
|
38
39
|
* Logger type for application-wide logging.
|
|
39
40
|
*/
|
|
40
|
-
type Logger =
|
|
41
|
+
type Logger = Logger$1;
|
|
41
42
|
/**
|
|
42
43
|
* Logger levels for application-wide logging.
|
|
43
44
|
*/
|
|
@@ -158,12 +159,14 @@ declare const _globalThis: typeof globalThis;
|
|
|
158
159
|
* - Returns a request-scoped logger from AsyncLocalStorage if available
|
|
159
160
|
* - Falls back to the global (singleton) logger
|
|
160
161
|
* - Initializes the global logger if not created yet
|
|
162
|
+
* - If newInstance is true, returns a fresh logger without any context
|
|
161
163
|
*
|
|
162
|
-
* @
|
|
164
|
+
* @param {boolean} newInstance - If true, returns a fresh logger without any context
|
|
165
|
+
* @returns {Logger} The logger instance (request-bound or global root logger or fresh instance)
|
|
163
166
|
*/
|
|
164
|
-
declare function getLogger(): Logger$1;
|
|
167
|
+
declare function getLogger(newInstance?: boolean): Logger$1;
|
|
165
168
|
/**
|
|
166
|
-
*
|
|
169
|
+
* Returns a fresh logger instance without any request context.
|
|
167
170
|
* This logger is used for logging messages that are not tied to a specific request.
|
|
168
171
|
*/
|
|
169
172
|
declare const logger: pino.Logger;
|
|
@@ -1182,12 +1185,190 @@ declare function createSignedToken(payload: Record<string, any>, secret: string,
|
|
|
1182
1185
|
*/
|
|
1183
1186
|
declare function verifySignedToken(token: string, secret: string): Record<string, any> | null;
|
|
1184
1187
|
|
|
1188
|
+
/**
|
|
1189
|
+
* Format options for the formatDate function
|
|
1190
|
+
*/
|
|
1191
|
+
interface DateFormatOptions {
|
|
1192
|
+
/** Date format pattern (default: 'yyyy-MM-dd') */
|
|
1193
|
+
format?: string;
|
|
1194
|
+
/** Locale to use for formatting (default: system locale) */
|
|
1195
|
+
locale?: string | string[];
|
|
1196
|
+
/** Time zone to use (default: system time zone) */
|
|
1197
|
+
timeZone?: string;
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Format a date according to the specified format pattern.
|
|
1201
|
+
*
|
|
1202
|
+
* @param date - Date to format
|
|
1203
|
+
* @param options - Formatting options
|
|
1204
|
+
* @returns Formatted date string
|
|
1205
|
+
*
|
|
1206
|
+
* @example
|
|
1207
|
+
* ```typescript
|
|
1208
|
+
* // Format as ISO date
|
|
1209
|
+
* formatDate(new Date(), { format: 'yyyy-MM-dd' }); // '2023-05-15'
|
|
1210
|
+
*
|
|
1211
|
+
* // Format with time
|
|
1212
|
+
* formatDate(new Date(), { format: 'yyyy-MM-dd HH:mm:ss' }); // '2023-05-15 14:30:22'
|
|
1213
|
+
*
|
|
1214
|
+
* // Format with locale
|
|
1215
|
+
* formatDate(new Date(), { format: 'PPPP', locale: 'fr-FR' }); // 'lundi 15 mai 2023'
|
|
1216
|
+
* ```
|
|
1217
|
+
*/
|
|
1218
|
+
declare function formatDate(date: Date | number, options?: DateFormatOptions): string;
|
|
1219
|
+
/**
|
|
1220
|
+
* Format a date as relative time (e.g., "5 minutes ago", "in 3 days").
|
|
1221
|
+
*
|
|
1222
|
+
* @param date - Date to format
|
|
1223
|
+
* @param now - Reference date (default: current time)
|
|
1224
|
+
* @param locale - Locale to use for formatting
|
|
1225
|
+
* @returns Formatted relative time string
|
|
1226
|
+
*/
|
|
1227
|
+
declare function formatRelativeTime(date: Date | number, now?: Date | number, locale?: string | string[]): string;
|
|
1228
|
+
/**
|
|
1229
|
+
* Parse a date string or timestamp into a Date object.
|
|
1230
|
+
*
|
|
1231
|
+
* @param input - Date string or timestamp to parse
|
|
1232
|
+
* @param fallback - Fallback date if parsing fails
|
|
1233
|
+
* @returns Parsed Date object or fallback
|
|
1234
|
+
*
|
|
1235
|
+
* @example
|
|
1236
|
+
* ```typescript
|
|
1237
|
+
* parseDate('2023-05-15'); // Date object for May 15, 2023
|
|
1238
|
+
* parseDate('invalid', new Date()); // Returns current date as fallback
|
|
1239
|
+
* ```
|
|
1240
|
+
*/
|
|
1241
|
+
declare function parseDate(input: string | number, fallback?: Date): Date | null;
|
|
1242
|
+
/**
|
|
1243
|
+
* Calculate the difference between two dates in the specified unit.
|
|
1244
|
+
*
|
|
1245
|
+
* @param date1 - First date
|
|
1246
|
+
* @param date2 - Second date (default: current time)
|
|
1247
|
+
* @param unit - Unit of time for the difference
|
|
1248
|
+
* @returns Difference in the specified unit
|
|
1249
|
+
*
|
|
1250
|
+
* @example
|
|
1251
|
+
* ```typescript
|
|
1252
|
+
* // Get difference in days
|
|
1253
|
+
* dateDiff(new Date('2023-05-15'), new Date('2023-05-10'), 'days'); // 5
|
|
1254
|
+
*
|
|
1255
|
+
* // Get difference in hours
|
|
1256
|
+
* dateDiff(new Date('2023-05-15T10:00:00'), new Date('2023-05-15T06:00:00'), 'hours'); // 4
|
|
1257
|
+
* ```
|
|
1258
|
+
*/
|
|
1259
|
+
declare function dateDiff(date1: Date | number, date2?: Date | number, unit?: 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years'): number;
|
|
1260
|
+
/**
|
|
1261
|
+
* Add a specified amount of time to a date.
|
|
1262
|
+
*
|
|
1263
|
+
* @param date - Base date
|
|
1264
|
+
* @param amount - Amount to add (can be negative)
|
|
1265
|
+
* @param unit - Unit of time to add
|
|
1266
|
+
* @returns New date with the addition
|
|
1267
|
+
*
|
|
1268
|
+
* @example
|
|
1269
|
+
* ```typescript
|
|
1270
|
+
* // Add 5 days
|
|
1271
|
+
* addToDate(new Date('2023-05-15'), 5, 'days'); // Date for May 20, 2023
|
|
1272
|
+
*
|
|
1273
|
+
* // Subtract 2 hours
|
|
1274
|
+
* addToDate(new Date('2023-05-15T10:00:00'), -2, 'hours'); // Date for May 15, 2023 08:00:00
|
|
1275
|
+
* ```
|
|
1276
|
+
*/
|
|
1277
|
+
declare function addToDate(date: Date | number, amount: number, unit: 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years'): Date;
|
|
1278
|
+
/**
|
|
1279
|
+
* Get the start of a time period containing the specified date.
|
|
1280
|
+
*
|
|
1281
|
+
* @param date - Date to get the start from
|
|
1282
|
+
* @param unit - Time unit
|
|
1283
|
+
* @returns Date object representing the start of the time unit
|
|
1284
|
+
*
|
|
1285
|
+
* @example
|
|
1286
|
+
* ```typescript
|
|
1287
|
+
* // Get start of day (midnight)
|
|
1288
|
+
* startOf(new Date('2023-05-15T14:30:00'), 'day'); // Date for May 15, 2023 00:00:00
|
|
1289
|
+
*
|
|
1290
|
+
* // Get start of month
|
|
1291
|
+
* startOf(new Date('2023-05-15'), 'month'); // Date for May 1, 2023
|
|
1292
|
+
* ```
|
|
1293
|
+
*/
|
|
1294
|
+
declare function startOf(date: Date | number, unit: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'): Date;
|
|
1295
|
+
/**
|
|
1296
|
+
* Get the end of a time period containing the specified date.
|
|
1297
|
+
*
|
|
1298
|
+
* @param date - Date to get the end from
|
|
1299
|
+
* @param unit - Time unit
|
|
1300
|
+
* @returns Date object representing the end of the time unit
|
|
1301
|
+
*
|
|
1302
|
+
* @example
|
|
1303
|
+
* ```typescript
|
|
1304
|
+
* // Get end of day (23:59:59.999)
|
|
1305
|
+
* endOf(new Date('2023-05-15T14:30:00'), 'day'); // Date for May 15, 2023 23:59:59.999
|
|
1306
|
+
*
|
|
1307
|
+
* // Get end of month
|
|
1308
|
+
* endOf(new Date('2023-05-15'), 'month'); // Date for May 31, 2023 23:59:59.999
|
|
1309
|
+
* ```
|
|
1310
|
+
*/
|
|
1311
|
+
declare function endOf(date: Date | number, unit: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'): Date;
|
|
1312
|
+
/**
|
|
1313
|
+
* Check if a date is between two other dates.
|
|
1314
|
+
*
|
|
1315
|
+
* @param date - Date to check
|
|
1316
|
+
* @param start - Start date of the range
|
|
1317
|
+
* @param end - End date of the range
|
|
1318
|
+
* @param inclusive - Whether the comparison should be inclusive of start/end
|
|
1319
|
+
* @returns True if the date is within the range
|
|
1320
|
+
*
|
|
1321
|
+
* @example
|
|
1322
|
+
* ```typescript
|
|
1323
|
+
* const date = new Date('2023-05-15');
|
|
1324
|
+
* const start = new Date('2023-05-10');
|
|
1325
|
+
* const end = new Date('2023-05-20');
|
|
1326
|
+
*
|
|
1327
|
+
* isBetween(date, start, end); // true
|
|
1328
|
+
* ```
|
|
1329
|
+
*/
|
|
1330
|
+
declare function isBetween(date: Date | number, start: Date | number, end: Date | number, inclusive?: boolean): boolean;
|
|
1331
|
+
/**
|
|
1332
|
+
* Check if a year is a leap year.
|
|
1333
|
+
*
|
|
1334
|
+
* @param year - Year to check (or date object)
|
|
1335
|
+
* @returns True if the year is a leap year
|
|
1336
|
+
*/
|
|
1337
|
+
declare function isLeapYear(year: number | Date): boolean;
|
|
1338
|
+
/**
|
|
1339
|
+
* Get the number of days in a month.
|
|
1340
|
+
*
|
|
1341
|
+
* @param year - Year
|
|
1342
|
+
* @param month - Month (0-11)
|
|
1343
|
+
* @returns Number of days in the month
|
|
1344
|
+
*/
|
|
1345
|
+
declare function daysInMonth(year: number | Date, month?: number): number;
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* Parameter decoration definition for method parameters
|
|
1349
|
+
*/
|
|
1350
|
+
interface ParamDefinition {
|
|
1351
|
+
/** Parameter position in method signature */
|
|
1352
|
+
index: number;
|
|
1353
|
+
/** Type of parameter (query, body, etc.) */
|
|
1354
|
+
type: 'query' | 'param' | 'body' | 'req' | 'res' | 'logger' | 'reqHeader' | 'reqId' | 'cookie';
|
|
1355
|
+
/** Optional key for extracting specific property */
|
|
1356
|
+
key?: string;
|
|
1357
|
+
/** Optional ParamOptions for advanced extraction */
|
|
1358
|
+
options?: ParamOptions;
|
|
1359
|
+
}
|
|
1185
1360
|
type Constructor<T = any> = new (...args: any[]) => T;
|
|
1186
1361
|
declare class DIContainer {
|
|
1187
1362
|
private instances;
|
|
1188
1363
|
private constructing;
|
|
1364
|
+
private propertyInjections;
|
|
1189
1365
|
register<T>(target: Constructor<T>): void;
|
|
1366
|
+
/**
|
|
1367
|
+
* Register a property injection to be resolved when the target class is instantiated
|
|
1368
|
+
*/
|
|
1369
|
+
registerPropertyInjection(target: object, propertyKey: string | symbol, injectClass: Constructor): void;
|
|
1190
1370
|
get<T>(target: Constructor<T>): T;
|
|
1371
|
+
private applyPropertyInjections;
|
|
1191
1372
|
clear(): void;
|
|
1192
1373
|
}
|
|
1193
1374
|
/**
|
|
@@ -1203,6 +1384,16 @@ declare function Injectable(): ClassDecorator;
|
|
|
1203
1384
|
* @returns Property decorator that injects the specified class into the property
|
|
1204
1385
|
*/
|
|
1205
1386
|
declare function Inject<T>(targetClass: new (...args: any[]) => T): PropertyDecorator;
|
|
1387
|
+
/**
|
|
1388
|
+
* Inject function for retrieving instances from the DI container.
|
|
1389
|
+
* @param targetClass - The class to inject
|
|
1390
|
+
*
|
|
1391
|
+
* @returns The instance of the requested class
|
|
1392
|
+
*
|
|
1393
|
+
* @example
|
|
1394
|
+
* const a = inject(TestClass);
|
|
1395
|
+
*/
|
|
1396
|
+
declare function inject<T>(targetClass: new (...args: any[]) => T): T;
|
|
1206
1397
|
/**
|
|
1207
1398
|
* Decorator for GET HTTP method routes.
|
|
1208
1399
|
*
|
|
@@ -1299,11 +1490,11 @@ declare const Connect: (path: string) => MethodDecorator;
|
|
|
1299
1490
|
*/
|
|
1300
1491
|
declare function Controller(basePath: string): ClassDecorator;
|
|
1301
1492
|
/**
|
|
1302
|
-
* Decorator that applies middleware to a controller method.
|
|
1493
|
+
* Decorator that applies middleware to a controller method or an entire controller.
|
|
1303
1494
|
* Multiple middlewares can be applied and will execute in order.
|
|
1304
1495
|
*
|
|
1305
1496
|
* @param middlewares - Express middleware functions to apply
|
|
1306
|
-
* @returns Method decorator
|
|
1497
|
+
* @returns Method decorator or Class decorator
|
|
1307
1498
|
*
|
|
1308
1499
|
* @example
|
|
1309
1500
|
* ```ts
|
|
@@ -1312,39 +1503,89 @@ declare function Controller(basePath: string): ClassDecorator;
|
|
|
1312
1503
|
* getProtectedResource() {
|
|
1313
1504
|
* // This route is protected by auth middleware
|
|
1314
1505
|
* }
|
|
1506
|
+
*
|
|
1507
|
+
* @Controller('/api')
|
|
1508
|
+
* @Use(commonMiddleware)
|
|
1509
|
+
* class ApiController {
|
|
1510
|
+
* // All routes in this controller use the middleware
|
|
1511
|
+
* }
|
|
1315
1512
|
* ```
|
|
1316
1513
|
*/
|
|
1317
|
-
declare function Use(...middlewares: RequestHandler[]): MethodDecorator;
|
|
1514
|
+
declare function Use(...middlewares: RequestHandler[]): MethodDecorator & ClassDecorator;
|
|
1515
|
+
/**
|
|
1516
|
+
* Options for parameter decorators
|
|
1517
|
+
* @template T - Type of the parameter value after transformation
|
|
1518
|
+
*
|
|
1519
|
+
* @property type - Base type of the parameter (default: 'string')'
|
|
1520
|
+
* @property dataType - Data structure type (single, array, object)
|
|
1521
|
+
* @property delimiter - Delimiter for array types
|
|
1522
|
+
* @property default - Default value if parameter is missing
|
|
1523
|
+
* @property required - Whether the parameter is required
|
|
1524
|
+
* @property throwError - Throw error on validation failure
|
|
1525
|
+
* @property validate - Custom validation function
|
|
1526
|
+
* @property transform - Custom transformation function
|
|
1527
|
+
*/
|
|
1528
|
+
interface ParamOptions<T = any> {
|
|
1529
|
+
/** Base type of the parameter (default: 'string') */
|
|
1530
|
+
type?: 'string' | 'number' | 'boolean';
|
|
1531
|
+
/** Data structure type (default: 'single') */
|
|
1532
|
+
dataType?: 'single' | 'array' | 'object';
|
|
1533
|
+
/** Delimiter for array types (default: ',') */
|
|
1534
|
+
delimiter?: string;
|
|
1535
|
+
/** Default value if parameter is missing */
|
|
1536
|
+
default?: T;
|
|
1537
|
+
/** Whether the parameter is required (default: false) */
|
|
1538
|
+
required?: boolean;
|
|
1539
|
+
/** Throw error on validation failure (default: true) */
|
|
1540
|
+
throwError?: boolean;
|
|
1541
|
+
/** Minimum value for number type */
|
|
1542
|
+
min?: number;
|
|
1543
|
+
/** Maximum value for number type */
|
|
1544
|
+
max?: number;
|
|
1545
|
+
/** Regex pattern the value must match */
|
|
1546
|
+
pattern?: RegExp;
|
|
1547
|
+
/** Name of the pattern for error messages */
|
|
1548
|
+
patternName?: string;
|
|
1549
|
+
/** Custom validation function */
|
|
1550
|
+
validate?: (value: any) => boolean;
|
|
1551
|
+
/** Custom transformation function */
|
|
1552
|
+
transform?: (value: any) => any;
|
|
1553
|
+
}
|
|
1554
|
+
declare function createParamDecorator(type: ParamDefinition['type'], key?: string): (paramKey?: string) => ParameterDecorator;
|
|
1555
|
+
declare function createParamDecoratorWithoutParam(type: ParamDefinition['type']): () => ParameterDecorator;
|
|
1318
1556
|
/**
|
|
1319
1557
|
* Decorator that extracts query parameters from request.
|
|
1320
1558
|
*
|
|
1321
1559
|
* @param paramKey - Optional key to extract specific query parameter
|
|
1560
|
+
* @param options - Optional ParamOptions
|
|
1322
1561
|
* @returns Parameter decorator
|
|
1323
1562
|
*
|
|
1324
1563
|
* @example
|
|
1325
1564
|
* ```ts
|
|
1326
1565
|
* @Get('/search')
|
|
1327
|
-
* search(@Query('term')
|
|
1328
|
-
* //
|
|
1566
|
+
* search(@Query('term') term: string, @Query('page', { type: 'number', default: 1 }) page: number) {
|
|
1567
|
+
* // term will contain the value of req.query.term
|
|
1568
|
+
* // page will contain the numeric value of req.query.page or default to 1
|
|
1329
1569
|
* }
|
|
1330
1570
|
* ```
|
|
1331
1571
|
*/
|
|
1332
|
-
declare const Query: (paramKey?: string) => ParameterDecorator;
|
|
1572
|
+
declare const Query: (paramKey?: string, options?: ParamOptions) => ParameterDecorator;
|
|
1333
1573
|
/**
|
|
1334
1574
|
* Decorator that extracts route parameters from request.
|
|
1335
1575
|
*
|
|
1336
1576
|
* @param paramKey - Optional key to extract specific route parameter
|
|
1577
|
+
* @param options - Optional ParamOptions
|
|
1337
1578
|
* @returns Parameter decorator
|
|
1338
1579
|
*
|
|
1339
|
-
*
|
|
1580
|
+
* @example
|
|
1340
1581
|
* ```ts
|
|
1341
1582
|
* @Get('/users/:id')
|
|
1342
|
-
* getUser(@Param('id')
|
|
1343
|
-
* //
|
|
1583
|
+
* getUser(@Param('id') id: string) {
|
|
1584
|
+
* // id will contain the value of req.params.id
|
|
1344
1585
|
* }
|
|
1345
1586
|
* ```
|
|
1346
1587
|
*/
|
|
1347
|
-
declare const Param: (paramKey?: string) => ParameterDecorator;
|
|
1588
|
+
declare const Param: (paramKey?: string, options?: ParamOptions) => ParameterDecorator;
|
|
1348
1589
|
/**
|
|
1349
1590
|
* Decorator that extracts body or body property from request.
|
|
1350
1591
|
*
|
|
@@ -1365,6 +1606,60 @@ declare const Param: (paramKey?: string) => ParameterDecorator;
|
|
|
1365
1606
|
* ```
|
|
1366
1607
|
*/
|
|
1367
1608
|
declare const Body: (paramKey?: string) => ParameterDecorator;
|
|
1609
|
+
/**
|
|
1610
|
+
* Decorator that injects a logger instance.
|
|
1611
|
+
* @returns Parameter decorator
|
|
1612
|
+
*
|
|
1613
|
+
* @example
|
|
1614
|
+
* ```ts
|
|
1615
|
+
* @Get('/log')
|
|
1616
|
+
* log(@ReqLogger() logger: Logger) {
|
|
1617
|
+
* logger.info('Logging request...');
|
|
1618
|
+
* }
|
|
1619
|
+
* ```
|
|
1620
|
+
*/
|
|
1621
|
+
declare const ReqLogger: () => ParameterDecorator;
|
|
1622
|
+
/**
|
|
1623
|
+
* Decorator that extracts request ID from headers.
|
|
1624
|
+
* @returns Parameter decorator
|
|
1625
|
+
*
|
|
1626
|
+
* @example
|
|
1627
|
+
* ```ts
|
|
1628
|
+
* @Get('/data')
|
|
1629
|
+
* getData(@ReqId() reqId: string) {
|
|
1630
|
+
* // reqId will contain the value of req.headers['x-request-id'] or req.id
|
|
1631
|
+
* }
|
|
1632
|
+
* ```
|
|
1633
|
+
*/
|
|
1634
|
+
declare const ReqId: () => ParameterDecorator;
|
|
1635
|
+
/**
|
|
1636
|
+
* Decorator that extracts request headers.
|
|
1637
|
+
* @param key - Optional key to extract specific header
|
|
1638
|
+
* @returns Parameter decorator
|
|
1639
|
+
*
|
|
1640
|
+
* @example
|
|
1641
|
+
* ```ts
|
|
1642
|
+
* @Get('/data')
|
|
1643
|
+
* getData(@ReqHeader('Authorization') authHeader: string) {
|
|
1644
|
+
* // authHeader will contain the value of req.headers['authorization']
|
|
1645
|
+
* }
|
|
1646
|
+
* ```
|
|
1647
|
+
*/
|
|
1648
|
+
declare const ReqHeader: (paramKey?: string) => ParameterDecorator;
|
|
1649
|
+
/**
|
|
1650
|
+
* Decorator that extracts cookies from request.
|
|
1651
|
+
* @param key - Optional key to extract specific cookie
|
|
1652
|
+
* @returns Parameter decorator
|
|
1653
|
+
*
|
|
1654
|
+
* @example
|
|
1655
|
+
* ```ts
|
|
1656
|
+
* @Get('/data')
|
|
1657
|
+
* getData(@ReqCookie('session_id') sessionId: string) {
|
|
1658
|
+
* // sessionId will contain the value of req.cookies['session_id']
|
|
1659
|
+
* }
|
|
1660
|
+
* ```
|
|
1661
|
+
*/
|
|
1662
|
+
declare const ReqCookie: (paramKey?: string) => ParameterDecorator;
|
|
1368
1663
|
/**
|
|
1369
1664
|
* Decorator that injects the entire request object.
|
|
1370
1665
|
*
|
|
@@ -1379,7 +1674,7 @@ declare const Body: (paramKey?: string) => ParameterDecorator;
|
|
|
1379
1674
|
* }
|
|
1380
1675
|
* ```
|
|
1381
1676
|
*/
|
|
1382
|
-
declare const Req: (
|
|
1677
|
+
declare const Req: () => ParameterDecorator;
|
|
1383
1678
|
/**
|
|
1384
1679
|
* Decorator that injects the response object.
|
|
1385
1680
|
*
|
|
@@ -1394,7 +1689,7 @@ declare const Req: (paramKey?: string) => ParameterDecorator;
|
|
|
1394
1689
|
* }
|
|
1395
1690
|
* ```
|
|
1396
1691
|
*/
|
|
1397
|
-
declare const Res: (
|
|
1692
|
+
declare const Res: () => ParameterDecorator;
|
|
1398
1693
|
/**
|
|
1399
1694
|
* Decorator that sets a custom HTTP status code for a response.
|
|
1400
1695
|
*
|
|
@@ -1464,7 +1759,7 @@ declare function Headers(headers: Record<string, string> | string, value?: strin
|
|
|
1464
1759
|
* Useful for pre-processing or logging.
|
|
1465
1760
|
*
|
|
1466
1761
|
* @param fn - Function to execute before the handler
|
|
1467
|
-
* @returns Method decorator
|
|
1762
|
+
* @returns Method decorator or Class decorator
|
|
1468
1763
|
*
|
|
1469
1764
|
* @example
|
|
1470
1765
|
* ```ts
|
|
@@ -1473,15 +1768,21 @@ declare function Headers(headers: Record<string, string> | string, value?: strin
|
|
|
1473
1768
|
* getUser(@Param('id') id: string) {
|
|
1474
1769
|
* // Function will log before this handler runs
|
|
1475
1770
|
* }
|
|
1771
|
+
*
|
|
1772
|
+
* @Controller('/api')
|
|
1773
|
+
* @Before((req, res) => console.log(`API access: ${req.path}`))
|
|
1774
|
+
* class ApiController {
|
|
1775
|
+
* // Hook runs before all routes in this controller
|
|
1776
|
+
* }
|
|
1476
1777
|
* ```
|
|
1477
1778
|
*/
|
|
1478
|
-
declare function Before(fn: Function): MethodDecorator;
|
|
1779
|
+
declare function Before(fn: Function): MethodDecorator & ClassDecorator;
|
|
1479
1780
|
/**
|
|
1480
1781
|
* Decorator that registers a function to run after route handler execution.
|
|
1481
1782
|
* Can access the handler's result.
|
|
1482
1783
|
*
|
|
1483
1784
|
* @param fn - Function to execute after the handler
|
|
1484
|
-
* @returns Method decorator
|
|
1785
|
+
* @returns Method decorator or Class decorator
|
|
1485
1786
|
*
|
|
1486
1787
|
* @example
|
|
1487
1788
|
* ```ts
|
|
@@ -1491,9 +1792,15 @@ declare function Before(fn: Function): MethodDecorator;
|
|
|
1491
1792
|
* // After this handler, the function will log the returned data
|
|
1492
1793
|
* return { id, name: 'Example' };
|
|
1493
1794
|
* }
|
|
1795
|
+
*
|
|
1796
|
+
* @Controller('/api')
|
|
1797
|
+
* @After((req, res, result) => console.log(`API response: ${JSON.stringify(result)}`))
|
|
1798
|
+
* class ApiController {
|
|
1799
|
+
* // Hook runs after all routes in this controller
|
|
1800
|
+
* }
|
|
1494
1801
|
* ```
|
|
1495
1802
|
*/
|
|
1496
|
-
declare function After(fn: Function): MethodDecorator;
|
|
1803
|
+
declare function After(fn: Function): MethodDecorator & ClassDecorator;
|
|
1497
1804
|
/**
|
|
1498
1805
|
* Decorator that requires specific roles for accessing a route.
|
|
1499
1806
|
* Must be used with authentication middleware.
|
|
@@ -1585,7 +1892,7 @@ declare function RateLimit(options: {
|
|
|
1585
1892
|
* Decorator that sets the content type for the response.
|
|
1586
1893
|
*
|
|
1587
1894
|
* @param type - MIME type for the response
|
|
1588
|
-
* @returns Method decorator
|
|
1895
|
+
* @returns Method decorator or Class decorator
|
|
1589
1896
|
*
|
|
1590
1897
|
* @example
|
|
1591
1898
|
* ```ts
|
|
@@ -1594,9 +1901,15 @@ declare function RateLimit(options: {
|
|
|
1594
1901
|
* downloadPdf() {
|
|
1595
1902
|
* return this.fileService.generatePdf();
|
|
1596
1903
|
* }
|
|
1904
|
+
*
|
|
1905
|
+
* @Controller('/api/json')
|
|
1906
|
+
* @ContentType('application/json')
|
|
1907
|
+
* class JsonApiController {
|
|
1908
|
+
* // All routes in this controller use this content type
|
|
1909
|
+
* }
|
|
1597
1910
|
* ```
|
|
1598
1911
|
*/
|
|
1599
|
-
declare function ContentType(type: string): MethodDecorator;
|
|
1912
|
+
declare function ContentType(type: string): MethodDecorator & ClassDecorator;
|
|
1600
1913
|
/**
|
|
1601
1914
|
* Decorator that adds API versioning to a route.
|
|
1602
1915
|
*
|
|
@@ -3489,6 +3802,142 @@ declare function isObject(value: unknown): value is Record<string, any>;
|
|
|
3489
3802
|
*/
|
|
3490
3803
|
declare function getAllPaths(obj: Record<string, any>, parentPath?: string): string[];
|
|
3491
3804
|
|
|
3805
|
+
/**
|
|
3806
|
+
* Options for timing function execution.
|
|
3807
|
+
*/
|
|
3808
|
+
interface TimingOptions {
|
|
3809
|
+
/** Optional label for the timing (defaults to function name) */
|
|
3810
|
+
label?: string;
|
|
3811
|
+
/** Whether to log the timing (default: false) */
|
|
3812
|
+
log?: boolean;
|
|
3813
|
+
/** Log level to use if logging is enabled (default: 'debug') */
|
|
3814
|
+
logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error';
|
|
3815
|
+
}
|
|
3816
|
+
/**
|
|
3817
|
+
* Result of a timing operation.
|
|
3818
|
+
*/
|
|
3819
|
+
interface TimingResult {
|
|
3820
|
+
/** Duration in milliseconds */
|
|
3821
|
+
durationMs: number;
|
|
3822
|
+
/** Duration in seconds */
|
|
3823
|
+
durationSec: number;
|
|
3824
|
+
/** Start timestamp */
|
|
3825
|
+
startTime: number;
|
|
3826
|
+
/** End timestamp */
|
|
3827
|
+
endTime: number;
|
|
3828
|
+
/** Label used for the timing */
|
|
3829
|
+
label: string;
|
|
3830
|
+
}
|
|
3831
|
+
/**
|
|
3832
|
+
* Measure the execution time of a synchronous function.
|
|
3833
|
+
*
|
|
3834
|
+
* @param fn - Function to measure
|
|
3835
|
+
* @param options - Timing options
|
|
3836
|
+
* @returns Result containing the return value and timing information
|
|
3837
|
+
*
|
|
3838
|
+
* @example
|
|
3839
|
+
* ```typescript
|
|
3840
|
+
* const { result, timing } = timeSync(() => {
|
|
3841
|
+
* // Some expensive operation
|
|
3842
|
+
* return computeResult();
|
|
3843
|
+
* }, { label: 'Computation', log: true });
|
|
3844
|
+
*
|
|
3845
|
+
* console.log(`Result: ${result}, took ${timing.durationMs}ms`);
|
|
3846
|
+
* ```
|
|
3847
|
+
*/
|
|
3848
|
+
declare function timeSync<T>(fn: () => T, options?: TimingOptions): {
|
|
3849
|
+
result: T;
|
|
3850
|
+
timing: TimingResult;
|
|
3851
|
+
};
|
|
3852
|
+
/**
|
|
3853
|
+
* Measure the execution time of an asynchronous function.
|
|
3854
|
+
*
|
|
3855
|
+
* @param fn - Async function to measure
|
|
3856
|
+
* @param options - Timing options
|
|
3857
|
+
* @returns Promise resolving to result and timing information
|
|
3858
|
+
*
|
|
3859
|
+
* @example
|
|
3860
|
+
* ```typescript
|
|
3861
|
+
* const { result, timing } = await timeAsync(async () => {
|
|
3862
|
+
* // Some expensive async operation
|
|
3863
|
+
* const data = await fetchData();
|
|
3864
|
+
* return processData(data);
|
|
3865
|
+
* }, { label: 'API Request', log: true });
|
|
3866
|
+
*
|
|
3867
|
+
* console.log(`Fetched ${result.length} items in ${timing.durationSec.toFixed(2)}s`);
|
|
3868
|
+
* ```
|
|
3869
|
+
*/
|
|
3870
|
+
declare function timeAsync<T>(fn: () => Promise<T>, options?: TimingOptions): Promise<{
|
|
3871
|
+
result: T;
|
|
3872
|
+
timing: TimingResult;
|
|
3873
|
+
}>;
|
|
3874
|
+
/**
|
|
3875
|
+
* Create a timing decorator for class methods.
|
|
3876
|
+
*
|
|
3877
|
+
* @param options - Timing options
|
|
3878
|
+
* @returns Method decorator
|
|
3879
|
+
*
|
|
3880
|
+
* @example
|
|
3881
|
+
* ```typescript
|
|
3882
|
+
* class DataService {
|
|
3883
|
+
* @timed({ log: true, logLevel: 'info' })
|
|
3884
|
+
* async fetchData() {
|
|
3885
|
+
* // ...implementation
|
|
3886
|
+
* }
|
|
3887
|
+
* }
|
|
3888
|
+
* ```
|
|
3889
|
+
*/
|
|
3890
|
+
declare function timed(options?: TimingOptions): (target: any, propertyKeyOrContext: string | symbol | any, descriptor?: PropertyDescriptor) => void;
|
|
3891
|
+
/**
|
|
3892
|
+
* Memoize function results with optional TTL and max cache size.
|
|
3893
|
+
*
|
|
3894
|
+
* @param fn - Function to memoize
|
|
3895
|
+
* @param options - Memoization options
|
|
3896
|
+
* @returns Memoized function
|
|
3897
|
+
*
|
|
3898
|
+
* @example
|
|
3899
|
+
* ```typescript
|
|
3900
|
+
* // Cache results for 30 seconds, with a maximum of 100 entries
|
|
3901
|
+
* const cachedFetch = memoize(
|
|
3902
|
+
* async (url) => {
|
|
3903
|
+
* const response = await fetch(url);
|
|
3904
|
+
* return response.json();
|
|
3905
|
+
* },
|
|
3906
|
+
* { ttl: 30000, maxSize: 100, cacheKey: (url) => url }
|
|
3907
|
+
* );
|
|
3908
|
+
* ```
|
|
3909
|
+
*/
|
|
3910
|
+
declare function memoize<T, Args extends any[]>(fn: (...args: Args) => T, options?: {
|
|
3911
|
+
/** Time-to-live in milliseconds (default: indefinite) */
|
|
3912
|
+
ttl?: number;
|
|
3913
|
+
/** Maximum cache size (default: unlimited) */
|
|
3914
|
+
maxSize?: number;
|
|
3915
|
+
/** Function to generate a cache key from arguments */
|
|
3916
|
+
cacheKey?: (...args: Args) => string;
|
|
3917
|
+
/** Auto-cleanup interval in milliseconds (default: disabled) */
|
|
3918
|
+
autoCleanupMs?: number;
|
|
3919
|
+
}): (...args: Args) => T;
|
|
3920
|
+
/**
|
|
3921
|
+
* Track memory usage for a function execution.
|
|
3922
|
+
*
|
|
3923
|
+
* @param fn - Function to track
|
|
3924
|
+
* @param options - Memory tracking options
|
|
3925
|
+
* @returns Result and memory usage information
|
|
3926
|
+
*/
|
|
3927
|
+
declare function trackMemoryUsage<T>(fn: () => T, options?: {
|
|
3928
|
+
/** Whether to log the memory usage (default: false) */
|
|
3929
|
+
log?: boolean;
|
|
3930
|
+
/** Label for the memory tracking (default: function name) */
|
|
3931
|
+
label?: string;
|
|
3932
|
+
}): {
|
|
3933
|
+
result: T;
|
|
3934
|
+
memoryUsage: {
|
|
3935
|
+
before: NodeJS.MemoryUsage;
|
|
3936
|
+
after: NodeJS.MemoryUsage;
|
|
3937
|
+
diff: Record<string, number>;
|
|
3938
|
+
};
|
|
3939
|
+
};
|
|
3940
|
+
|
|
3492
3941
|
/**
|
|
3493
3942
|
* Options for parsing and validating request parameters.
|
|
3494
3943
|
*/
|
|
@@ -3573,6 +4022,92 @@ declare function extractSortParams(query: Record<string, string | string[]>, all
|
|
|
3573
4022
|
*/
|
|
3574
4023
|
declare function extractFilterParams(query: Record<string, string | string[]>, allowedFilters: string[]): Record<string, string | string[]>;
|
|
3575
4024
|
|
|
4025
|
+
/**
|
|
4026
|
+
* Convert a buffer or string to a readable stream.
|
|
4027
|
+
*
|
|
4028
|
+
* @param data - Buffer or string to convert
|
|
4029
|
+
* @returns Readable stream containing the data
|
|
4030
|
+
*
|
|
4031
|
+
* @example
|
|
4032
|
+
* ```typescript
|
|
4033
|
+
* const stream = bufferToStream(Buffer.from('Hello world'));
|
|
4034
|
+
* // or
|
|
4035
|
+
* const stream = bufferToStream('Hello world');
|
|
4036
|
+
* ```
|
|
4037
|
+
*/
|
|
4038
|
+
declare function bufferToStream(data: Buffer | string): Readable;
|
|
4039
|
+
/**
|
|
4040
|
+
* Convert a readable stream to a buffer.
|
|
4041
|
+
*
|
|
4042
|
+
* @param stream - Readable stream to convert
|
|
4043
|
+
* @returns Promise resolving to a buffer containing all stream data
|
|
4044
|
+
*
|
|
4045
|
+
* @example
|
|
4046
|
+
* ```typescript
|
|
4047
|
+
* const buffer = await streamToBuffer(fs.createReadStream('file.txt'));
|
|
4048
|
+
* console.log(buffer.toString()); // Contents of file.txt
|
|
4049
|
+
* ```
|
|
4050
|
+
*/
|
|
4051
|
+
declare function streamToBuffer(stream: Readable): Promise<Buffer>;
|
|
4052
|
+
/**
|
|
4053
|
+
* Convert a readable stream to a string.
|
|
4054
|
+
*
|
|
4055
|
+
* @param stream - Readable stream to convert
|
|
4056
|
+
* @param encoding - Character encoding (default: 'utf8')
|
|
4057
|
+
* @returns Promise resolving to a string containing all stream data
|
|
4058
|
+
*
|
|
4059
|
+
* @example
|
|
4060
|
+
* ```typescript
|
|
4061
|
+
* const content = await streamToString(fs.createReadStream('file.txt'));
|
|
4062
|
+
* console.log(content); // Contents of file.txt as string
|
|
4063
|
+
* ```
|
|
4064
|
+
*/
|
|
4065
|
+
declare function streamToString(stream: Readable, encoding?: BufferEncoding): Promise<string>;
|
|
4066
|
+
/**
|
|
4067
|
+
* Create a transform stream that limits the rate of data flow.
|
|
4068
|
+
*
|
|
4069
|
+
* @param bytesPerSecond - Maximum bytes per second
|
|
4070
|
+
* @returns Transform stream that throttles data flow
|
|
4071
|
+
*/
|
|
4072
|
+
declare function createThrottleStream(bytesPerSecond: number): Transform;
|
|
4073
|
+
/**
|
|
4074
|
+
* Create a transform stream that batches data into chunks of specified size.
|
|
4075
|
+
*
|
|
4076
|
+
* @param size - Size of each batch (items for object mode, bytes for binary mode)
|
|
4077
|
+
* @param options - Stream options
|
|
4078
|
+
* @returns Transform stream that batches data
|
|
4079
|
+
*
|
|
4080
|
+
* @example
|
|
4081
|
+
* ```typescript
|
|
4082
|
+
* // Batch lines from a file into arrays of 100 lines each
|
|
4083
|
+
* createReadStream('large-file.txt')
|
|
4084
|
+
* .pipe(createLineStream())
|
|
4085
|
+
* .pipe(createBatchStream(100))
|
|
4086
|
+
* .on('data', batch => console.log(`Processing batch of ${batch.length} lines`));
|
|
4087
|
+
* ```
|
|
4088
|
+
*/
|
|
4089
|
+
declare function createBatchStream(size: number, options?: {
|
|
4090
|
+
objectMode?: boolean;
|
|
4091
|
+
}): Transform;
|
|
4092
|
+
/**
|
|
4093
|
+
* Create a transform stream that splits text data by newlines.
|
|
4094
|
+
*
|
|
4095
|
+
* @param options - Options for the line stream
|
|
4096
|
+
* @returns Transform stream that emits lines
|
|
4097
|
+
*
|
|
4098
|
+
* @example
|
|
4099
|
+
* ```typescript
|
|
4100
|
+
* // Process a file line by line
|
|
4101
|
+
* createReadStream('file.txt')
|
|
4102
|
+
* .pipe(createLineStream())
|
|
4103
|
+
* .on('data', line => console.log(`Line: ${line}`));
|
|
4104
|
+
* ```
|
|
4105
|
+
*/
|
|
4106
|
+
declare function createLineStream(options?: {
|
|
4107
|
+
encoding?: BufferEncoding;
|
|
4108
|
+
includeNewlines?: boolean;
|
|
4109
|
+
}): Transform;
|
|
4110
|
+
|
|
3576
4111
|
/**
|
|
3577
4112
|
* Capitalizes the first character of a string.
|
|
3578
4113
|
*
|
|
@@ -3666,6 +4201,96 @@ declare function reverse(str: string): string;
|
|
|
3666
4201
|
*/
|
|
3667
4202
|
declare function countOccurrences(str: string, substring: string, caseSensitive?: boolean): number;
|
|
3668
4203
|
|
|
4204
|
+
/**
|
|
4205
|
+
* Check if a value is of a specific primitive type.
|
|
4206
|
+
*
|
|
4207
|
+
* @param value - Value to check
|
|
4208
|
+
* @param type - Type to check against
|
|
4209
|
+
* @returns Whether the value is of the specified type
|
|
4210
|
+
*
|
|
4211
|
+
* @example
|
|
4212
|
+
* ```typescript
|
|
4213
|
+
* isPrimitiveType('hello', 'string'); // true
|
|
4214
|
+
* isPrimitiveType(42, 'number'); // true
|
|
4215
|
+
* isPrimitiveType(true, 'boolean'); // true
|
|
4216
|
+
* isPrimitiveType(null, 'null'); // true
|
|
4217
|
+
* isPrimitiveType(undefined, 'undefined'); // true
|
|
4218
|
+
* isPrimitiveType({}, 'object'); // true
|
|
4219
|
+
* isPrimitiveType([], 'array'); // true
|
|
4220
|
+
* ```
|
|
4221
|
+
*/
|
|
4222
|
+
declare function isPrimitiveType(value: unknown, type: 'string' | 'number' | 'boolean' | 'symbol' | 'bigint' | 'function' | 'object' | 'array' | 'null' | 'undefined'): boolean;
|
|
4223
|
+
/**
|
|
4224
|
+
* Get the primitive type of a value as a string.
|
|
4225
|
+
*
|
|
4226
|
+
* @param value - Value to get the type of
|
|
4227
|
+
* @returns String representing the type
|
|
4228
|
+
*
|
|
4229
|
+
* @example
|
|
4230
|
+
* ```typescript
|
|
4231
|
+
* getTypeOf('hello'); // 'string'
|
|
4232
|
+
* getTypeOf(42); // 'number'
|
|
4233
|
+
* getTypeOf([]); // 'array'
|
|
4234
|
+
* getTypeOf(null); // 'null'
|
|
4235
|
+
* ```
|
|
4236
|
+
*/
|
|
4237
|
+
declare function getTypeOf(value: unknown): string;
|
|
4238
|
+
/**
|
|
4239
|
+
* Type guard for checking if a value is an array of a specific type.
|
|
4240
|
+
*
|
|
4241
|
+
* @param value - Value to check
|
|
4242
|
+
* @param itemTypeGuard - Function that checks if items are of the expected type
|
|
4243
|
+
* @returns True if the value is an array with items of the expected type
|
|
4244
|
+
*
|
|
4245
|
+
* @example
|
|
4246
|
+
* ```typescript
|
|
4247
|
+
* isArrayOf([1, 2, 3], (item): item is number => typeof item === 'number'); // true
|
|
4248
|
+
* isArrayOf(['a', 'b', 'c'], (item): item is string => typeof item === 'string'); // true
|
|
4249
|
+
* isArrayOf([1, '2', 3], (item): item is number => typeof item === 'number'); // false
|
|
4250
|
+
* ```
|
|
4251
|
+
*/
|
|
4252
|
+
declare function isArrayOf<T>(value: unknown, itemTypeGuard: (item: unknown) => item is T): value is T[];
|
|
4253
|
+
/**
|
|
4254
|
+
* Convert a value to a string.
|
|
4255
|
+
*
|
|
4256
|
+
* @param value - Value to convert
|
|
4257
|
+
* @param defaultValue - Default value if conversion fails
|
|
4258
|
+
* @returns String representation of the value
|
|
4259
|
+
*/
|
|
4260
|
+
declare function toStr(value: unknown, defaultValue?: string): string;
|
|
4261
|
+
/**
|
|
4262
|
+
* Convert a value to a number.
|
|
4263
|
+
*
|
|
4264
|
+
* @param value - Value to convert
|
|
4265
|
+
* @param defaultValue - Default value if conversion fails
|
|
4266
|
+
* @returns Numeric representation of the value
|
|
4267
|
+
*/
|
|
4268
|
+
declare function toNum(value: unknown, defaultValue?: number): number;
|
|
4269
|
+
/**
|
|
4270
|
+
* Convert a value to a boolean.
|
|
4271
|
+
*
|
|
4272
|
+
* @param value - Value to convert
|
|
4273
|
+
* @param defaultValue - Default value if conversion fails
|
|
4274
|
+
* @returns Boolean representation of the value
|
|
4275
|
+
*/
|
|
4276
|
+
declare function toBool(value: unknown, defaultValue?: boolean): boolean;
|
|
4277
|
+
/**
|
|
4278
|
+
* Ensure a value matches the expected type, or provide a default.
|
|
4279
|
+
*
|
|
4280
|
+
* @param value - Value to check
|
|
4281
|
+
* @param expectedType - Expected primitive type
|
|
4282
|
+
* @param defaultValue - Default value to use if type doesn't match
|
|
4283
|
+
* @returns The value if it matches the type, otherwise the default
|
|
4284
|
+
*
|
|
4285
|
+
* @example
|
|
4286
|
+
* ```typescript
|
|
4287
|
+
* ensureType(42, 'number', 0); // 42
|
|
4288
|
+
* ensureType('42', 'number', 0); // 0
|
|
4289
|
+
* ensureType(undefined, 'string', 'default'); // 'default'
|
|
4290
|
+
* ```
|
|
4291
|
+
*/
|
|
4292
|
+
declare function ensureType<T>(value: unknown, expectedType: string, defaultValue: T): T;
|
|
4293
|
+
|
|
3669
4294
|
/**
|
|
3670
4295
|
* Appends query parameters to a given URL.
|
|
3671
4296
|
*
|
|
@@ -5128,4 +5753,4 @@ declare class ServerConfigBuilder {
|
|
|
5128
5753
|
private setEnabled;
|
|
5129
5754
|
}
|
|
5130
5755
|
|
|
5131
|
-
export { After, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AsyncOperationResponse, type Awaited$1 as Awaited, BUILD_MARKER, BadGatewayException, BadRequestException, type BatchResponse, Before, Body, type BufferEncoding, Cache, CircuitBreakerOpenError, type CircuitBreakerOptions, CircuitBreakerState, ConflictException, Connect, ContentType, ContextStore, Controller, DIContainer, type DecryptionOptions, type DeepPartial, type DeepReadonly, type DeepRequired, type DeepStringifyOrNull, Delete, type EncryptionOptions, type EncryptionResult, Env, Environment, type ErrorHandlerOptions, ErrorResponse, ExpressServer, ForbiddenException, type Func, GatewayTimeoutException, Get, Head, Header, Headers, HttpCode, HttpError, HttpStatusCodes, Inject, Injectable, InsufficientStorageException, InternalServerErrorException, type IsEqual, type KeysOfType, Log, type Logger, type LoggerLevels, type MaybePromise, MethodNotAllowedException, type Middleware, type Mutable, NoContentResponse, type NonEmptyArray, NotAcceptableException, NotFoundException, type Nullable, type Optional, type Optional2, Options, PaginatedResponse, type Pagination, type PaginationParams, type PaginationResponse, Param, type PartialPick, Patch, type PathOptions, PayloadTooLargeException, type PickByType, Post, type Primitive, Put, Query, RateLimit, type RecordOptional, Redirect, RedirectResponse, Req, RequestTimeoutException, type RequireAtLeastOne, Res, Roles, type ServerConfig, ServerConfigBuilder, type ServerHooks, ServiceUnavailableException, SortDirection, type Store, StoreKeys, type StreamResponse, type StringKeyedRecord, SuccessResponse, TTLCache, type TTLCacheOptions, type TaskQueue, Timeout, type ToggleConfig, TooManyRequestsException, Trace, TypedContextKey, UnauthorizedException, type UnionToIntersection, UnprocessableEntityException, UnsupportedMediaTypeException, type UrlOptions, Use, type ValidationOptions, type ValidationResult, type ValueOf, Version, type WithPagination, type Without, type Writable, _globalThis, abortable, addRedactFields, addSensitiveFields, appendQueryParams, appendTextFile, capitalize, chunk, circuitBreaker, compact, copyDir, copyFile, countBy, countOccurrences, createChildLogger, createDeferred, createDirectory, createErrorResponse, createFinalErrorResponse, createHttpError, createPaginatedResponse, createRequestLogger, createSignedToken, createSuccessResponse, createTaskQueue, createTempDir, createTempFile, createUrlBuilder, debounce, decrypt, deepFreeze, deepObjMerge, defaultSensitiveFields, deleteDirRecursive, deleteFileIfExists, difference, emptyDir, encrypt, ensureDir, ensureEmptyDir, equalsIgnoreCase, errorHandler, extractFilterParams, extractPaginationParams, extractQueryParams, extractSortParams, fileExists, filterObject, findFilesByPattern, findInDir, findNewestFile, findOldestFile, flattenDeep, flattenObject, generateApiKey, generateRandomBytes, generateRandomBytesAsString, getAllPaths, getConfig, getDirSize, getDirStats, getDomain, getErrorMessage, getExtension, getFileSize, getFileStats, getFromContext, getLogger, getPaginationParams, getRedactCensor, getRequestId, getSubdirectories, getValueByPath, groupBy, hasErrorShape, hasRequiredProps, hash, healthCheck, hmac, intersect, isAlpha, isAlphanumeric, isArray, isBase64, isCreditCard, isDateInRange, isDirectory, isEmail, isEqual, isFile, isHexColor, isHttpError, isIPv4, isIPv6, isISODate, isLengthBetween, isNumberBetween, isNumeric, isObjEmpty, isObject, isPhone, isPlainObject, isPort, isStrongPassword, isURL, isUUID, isValidJSON, isValidUrl, joinPaths, listFiles, logError, logger, mapObject, mask, matchesPattern, md5, memoizeAsync, mergeSort, moveDir, moveFile, nanoId, normalizeUrl, omit, parseBooleanParam, parseNumberParam, parseQueryString, parseTypedQueryParams, partition, pick, pluck, random, randomBase64, randomHex, randomInt, randomString, range, rateLimit, readDirectory, readFileBuffer, readJsonFile, readTextFile, redact, registerControllers, removeQueryParams, requestId, responseTime, retry, reverse, runInBatches, runInSeries, runWithConcurrency, safeCompare, safeReadJsonFile, sendResponse, setConfig, setRedactCensor, setSensitiveFields, setValueByPath, settleAll, setupRequestContext, sha1, sha256, sha256Hmac, shuffle, singletonAsync, sleep, slugify, streamFile, stripHtml, take, takeWhile, throttle, timeout, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, truncate, unique, uuid, validateAll, verifySignedToken, walkDir, watchDir, watchDirRecursive, waterfall, withErrorHandling, withTimeout, writeJsonFile, writeTextFile, zip };
|
|
5756
|
+
export { After, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AsyncOperationResponse, type Awaited$1 as Awaited, BUILD_MARKER, BadGatewayException, BadRequestException, type BatchResponse, Before, Body, type BufferEncoding, Cache, CircuitBreakerOpenError, type CircuitBreakerOptions, CircuitBreakerState, ConflictException, Connect, ContentType, ContextStore, Controller, DIContainer, type DateFormatOptions, type DecryptionOptions, type DeepPartial, type DeepReadonly, type DeepRequired, type DeepStringifyOrNull, Delete, type EncryptionOptions, type EncryptionResult, Env, Environment, type ErrorHandlerOptions, ErrorResponse, ExpressServer, ForbiddenException, type Func, GatewayTimeoutException, Get, Head, Header, Headers, HttpCode, HttpError, HttpStatusCodes, Inject, Injectable, InsufficientStorageException, InternalServerErrorException, type IsEqual, type KeysOfType, Log, type Logger, type LoggerLevels, type MaybePromise, MethodNotAllowedException, type Middleware, type Mutable, NoContentResponse, type NonEmptyArray, NotAcceptableException, NotFoundException, type Nullable, type Optional, type Optional2, Options, PaginatedResponse, type Pagination, type PaginationParams, type PaginationResponse, Param, type ParamOptions, type PartialPick, Patch, type PathOptions, PayloadTooLargeException, type PickByType, Post, type Primitive, Put, Query, RateLimit, type RecordOptional, Redirect, RedirectResponse, Req, ReqCookie, ReqHeader, ReqId, ReqLogger, RequestTimeoutException, type RequireAtLeastOne, Res, Roles, type ServerConfig, ServerConfigBuilder, type ServerHooks, ServiceUnavailableException, SortDirection, type Store, StoreKeys, type StreamResponse, type StringKeyedRecord, SuccessResponse, TTLCache, type TTLCacheOptions, type TaskQueue, Timeout, type TimingOptions, type TimingResult, type ToggleConfig, TooManyRequestsException, Trace, TypedContextKey, UnauthorizedException, type UnionToIntersection, UnprocessableEntityException, UnsupportedMediaTypeException, type UrlOptions, Use, type ValidationOptions, type ValidationResult, type ValueOf, Version, type WithPagination, type Without, type Writable, _globalThis, abortable, addRedactFields, addSensitiveFields, addToDate, appendQueryParams, appendTextFile, bufferToStream, capitalize, chunk, circuitBreaker, compact, copyDir, copyFile, countBy, countOccurrences, createBatchStream, createChildLogger, createDeferred, createDirectory, createErrorResponse, createFinalErrorResponse, createHttpError, createLineStream, createPaginatedResponse, createParamDecorator, createParamDecoratorWithoutParam, createRequestLogger, createSignedToken, createSuccessResponse, createTaskQueue, createTempDir, createTempFile, createThrottleStream, createUrlBuilder, dateDiff, daysInMonth, debounce, decrypt, deepFreeze, deepObjMerge, defaultSensitiveFields, deleteDirRecursive, deleteFileIfExists, difference, emptyDir, encrypt, endOf, ensureDir, ensureEmptyDir, ensureType, equalsIgnoreCase, errorHandler, extractFilterParams, extractPaginationParams, extractQueryParams, extractSortParams, fileExists, filterObject, findFilesByPattern, findInDir, findNewestFile, findOldestFile, flattenDeep, flattenObject, formatDate, formatRelativeTime, generateApiKey, generateRandomBytes, generateRandomBytesAsString, getAllPaths, getConfig, getDirSize, getDirStats, getDomain, getErrorMessage, getExtension, getFileSize, getFileStats, getFromContext, getLogger, getPaginationParams, getRedactCensor, getRequestId, getSubdirectories, getTypeOf, getValueByPath, groupBy, hasErrorShape, hasRequiredProps, hash, healthCheck, hmac, inject, intersect, isAlpha, isAlphanumeric, isArray, isArrayOf, isBase64, isBetween, isCreditCard, isDateInRange, isDirectory, isEmail, isEqual, isFile, isHexColor, isHttpError, isIPv4, isIPv6, isISODate, isLeapYear, isLengthBetween, isNumberBetween, isNumeric, isObjEmpty, isObject, isPhone, isPlainObject, isPort, isPrimitiveType, isStrongPassword, isURL, isUUID, isValidJSON, isValidUrl, joinPaths, listFiles, logError, logger, mapObject, mask, matchesPattern, md5, memoize, memoizeAsync, mergeSort, moveDir, moveFile, nanoId, normalizeUrl, omit, parseBooleanParam, parseDate, parseNumberParam, parseQueryString, parseTypedQueryParams, partition, pick, pluck, random, randomBase64, randomHex, randomInt, randomString, range, rateLimit, readDirectory, readFileBuffer, readJsonFile, readTextFile, redact, registerControllers, removeQueryParams, requestId, responseTime, retry, reverse, runInBatches, runInSeries, runWithConcurrency, safeCompare, safeReadJsonFile, sendResponse, setConfig, setRedactCensor, setSensitiveFields, setValueByPath, settleAll, setupRequestContext, sha1, sha256, sha256Hmac, shuffle, singletonAsync, sleep, slugify, startOf, streamFile, streamToBuffer, streamToString, stripHtml, take, takeWhile, throttle, timeAsync, timeSync, timed, timeout, toBool, toCamelCase, toKebabCase, toNum, toPascalCase, toSnakeCase, toStr, trackMemoryUsage, truncate, unique, uuid, validateAll, verifySignedToken, walkDir, watchDir, watchDirRecursive, waterfall, withErrorHandling, withTimeout, writeJsonFile, writeTextFile, zip };
|