@catbee/utils 0.0.8-rc.2 → 0.0.8-rc.4

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.
Files changed (66) hide show
  1. package/build/index.cjs +6591 -0
  2. package/build/index.d.ts +5131 -0
  3. package/build/index.mjs +6321 -0
  4. package/package.json +12 -36
  5. package/build/esm/config.d.ts +0 -121
  6. package/build/esm/config.js +0 -132
  7. package/build/esm/index.d.ts +0 -26
  8. package/build/esm/index.js +0 -49
  9. package/build/esm/servers/server.builder.d.ts +0 -507
  10. package/build/esm/servers/server.builder.js +0 -654
  11. package/build/esm/servers/server.d.ts +0 -255
  12. package/build/esm/servers/server.js +0 -963
  13. package/build/esm/types/api-response.d.ts +0 -151
  14. package/build/esm/types/api-response.js +0 -33
  15. package/build/esm/types/index.d.ts +0 -124
  16. package/build/esm/types/index.js +0 -24
  17. package/build/esm/types/server.d.ts +0 -267
  18. package/build/esm/types/server.js +0 -24
  19. package/build/esm/utils/array.utils.d.ts +0 -167
  20. package/build/esm/utils/array.utils.js +0 -344
  21. package/build/esm/utils/async.utils.d.ts +0 -264
  22. package/build/esm/utils/async.utils.js +0 -619
  23. package/build/esm/utils/cache.utils.d.ts +0 -152
  24. package/build/esm/utils/cache.utils.js +0 -294
  25. package/build/esm/utils/context-store.utils.d.ts +0 -188
  26. package/build/esm/utils/context-store.utils.js +0 -290
  27. package/build/esm/utils/crypto.utils.d.ts +0 -159
  28. package/build/esm/utils/crypto.utils.js +0 -278
  29. package/build/esm/utils/date.utils.d.ts +0 -158
  30. package/build/esm/utils/date.utils.js +0 -383
  31. package/build/esm/utils/decorators.utils.d.ts +0 -511
  32. package/build/esm/utils/decorators.utils.js +0 -1013
  33. package/build/esm/utils/dir.utils.d.ts +0 -195
  34. package/build/esm/utils/dir.utils.js +0 -476
  35. package/build/esm/utils/env.utils.d.ts +0 -376
  36. package/build/esm/utils/env.utils.js +0 -782
  37. package/build/esm/utils/exception.utils.d.ts +0 -229
  38. package/build/esm/utils/exception.utils.js +0 -382
  39. package/build/esm/utils/fs.utils.d.ts +0 -163
  40. package/build/esm/utils/fs.utils.js +0 -348
  41. package/build/esm/utils/http-status-codes.d.ts +0 -265
  42. package/build/esm/utils/http-status-codes.js +0 -294
  43. package/build/esm/utils/id.utils.d.ts +0 -35
  44. package/build/esm/utils/id.utils.js +0 -83
  45. package/build/esm/utils/logger.utils.d.ts +0 -159
  46. package/build/esm/utils/logger.utils.js +0 -304
  47. package/build/esm/utils/middleware.utils.d.ts +0 -99
  48. package/build/esm/utils/middleware.utils.js +0 -235
  49. package/build/esm/utils/obj.utils.d.ts +0 -123
  50. package/build/esm/utils/obj.utils.js +0 -412
  51. package/build/esm/utils/performance.utils.d.ts +0 -135
  52. package/build/esm/utils/performance.utils.js +0 -273
  53. package/build/esm/utils/request.utils.d.ts +0 -85
  54. package/build/esm/utils/request.utils.js +0 -190
  55. package/build/esm/utils/response.utils.d.ts +0 -162
  56. package/build/esm/utils/response.utils.js +0 -261
  57. package/build/esm/utils/stream.utils.d.ts +0 -87
  58. package/build/esm/utils/stream.utils.js +0 -209
  59. package/build/esm/utils/string.utils.d.ts +0 -92
  60. package/build/esm/utils/string.utils.js +0 -164
  61. package/build/esm/utils/type.utils.d.ts +0 -89
  62. package/build/esm/utils/type.utils.js +0 -186
  63. package/build/esm/utils/url.utils.d.ts +0 -140
  64. package/build/esm/utils/url.utils.js +0 -303
  65. package/build/esm/utils/validate.utils.d.ts +0 -176
  66. package/build/esm/utils/validate.utils.js +0 -319
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@catbee/utils",
3
- "version": "0.0.8-rc.2",
3
+ "version": "0.0.8-rc.4",
4
4
  "description": "A modular, production-grade utility toolkit for Node.js and TypeScript, designed for robust, scalable applications (including Express-based services). All utilities are tree-shakable and can be imported independently.",
5
- "main": "build/esm/index.js",
6
- "module": "build/esm/index.js",
7
- "types": "build/esm/index.d.ts",
5
+ "main": "build/index.cjs",
6
+ "module": "build/index.mjs",
7
+ "types": "build/index.d.ts",
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },
@@ -13,35 +13,6 @@
13
13
  "email": "hprasath.dev@gmail.com"
14
14
  },
15
15
  "license": "MIT",
16
- "keywords": [
17
- "utils",
18
- "utility",
19
- "helpers",
20
- "typescript",
21
- "nodejs",
22
- "env",
23
- "config",
24
- "logger",
25
- "pino",
26
- "context",
27
- "context-store",
28
- "async",
29
- "validation",
30
- "filesystem",
31
- "object",
32
- "string",
33
- "array",
34
- "crypto",
35
- "catbee",
36
- "express",
37
- "http",
38
- "middleware",
39
- "metrics",
40
- "monitoring",
41
- "decorators",
42
- "functional",
43
- "tools"
44
- ],
45
16
  "optionalDependencies": {
46
17
  "@scalar/express-api-reference": "^0.8.18",
47
18
  "abort-controller": "^3.0.0",
@@ -55,19 +26,24 @@
55
26
  "prom-client": "^15.1.3"
56
27
  },
57
28
  "peerDependencies": {
58
- "express": "^5.1.0"
29
+ "express": "^5.1.0",
30
+ "reflect-metadata": "^0.2.2"
59
31
  },
60
32
  "peerDependenciesMeta": {
61
33
  "express": {
62
34
  "optional": true
35
+ },
36
+ "reflect-metadata": {
37
+ "optional": true
63
38
  }
64
39
  },
65
40
  "engines": {
66
41
  "node": ">=18.4"
67
42
  },
68
43
  "files": [
69
- "build/esm/**/*.js",
70
- "build/esm/**/*.d.ts",
44
+ "build/**/*.mjs",
45
+ "build/**/*.cjs",
46
+ "build/**/*.d.ts",
71
47
  "LICENSE",
72
48
  "README.md"
73
49
  ]
@@ -1,121 +0,0 @@
1
- import { Logger, LoggerLevels } from './utils/logger.utils';
2
- /**
3
- * Extends Express Request interface to add request ID tracking.
4
- * Added by requestId middleware during request processing.
5
- */
6
- declare global {
7
- namespace Express {
8
- interface Request {
9
- /** Unique request identifier (set by middleware) */
10
- id?: string;
11
- /** Logger instance for the request (set by middleware) */
12
- logger?: Logger;
13
- /** User information (set by authentication middleware) */
14
- user?: any;
15
- }
16
- }
17
- }
18
- /**
19
- * Application runtime configuration loaded from environment variables.
20
- */
21
- export declare let config: {
22
- logger: {
23
- /**
24
- * Logging level (e.g., 'info', 'debug', 'warn', 'error').
25
- */
26
- level: LoggerLevels;
27
- /**
28
- * Name of the logger instance (defaults to npm package name).
29
- */
30
- name: string;
31
- /**
32
- * Enables pretty-print logging in development.
33
- * Has no effect in production.
34
- */
35
- pretty: boolean;
36
- /**
37
- * Single line output for pretty-print (default: false)
38
- */
39
- singleLine: boolean;
40
- };
41
- cache: {
42
- /**
43
- * Default TTL (time to live) for cache entries in seconds
44
- */
45
- defaultTtl: number;
46
- };
47
- };
48
- export declare const defaultServerConfig: {
49
- port: number;
50
- host: string;
51
- cors: false;
52
- helmet: false;
53
- compression: false;
54
- bodyParser: {
55
- json: {
56
- limit: string;
57
- };
58
- urlencoded: {
59
- extended: true;
60
- limit: string;
61
- };
62
- };
63
- cookieParser: false;
64
- isMicroservice: false;
65
- appName: string;
66
- globalHeaders: {};
67
- rateLimit: {
68
- enable: false;
69
- windowMs: number;
70
- max: number;
71
- message: string;
72
- standardHeaders: true;
73
- legacyHeaders: false;
74
- };
75
- requestLogging: {
76
- enable: boolean;
77
- ignorePaths: (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, _res: import("express").Response<any, Record<string, any>>) => boolean;
78
- skipNotFoundRoutes: false;
79
- };
80
- openApi: {
81
- enable: false;
82
- mountPath: string;
83
- verbose: false;
84
- withGlobalPrefix: false;
85
- };
86
- healthCheck: {
87
- path: string;
88
- detailed: true;
89
- };
90
- requestTimeout: number;
91
- responseTime: {
92
- enable: false;
93
- addHeader: true;
94
- logOnComplete: false;
95
- };
96
- requestId: {
97
- headerName: string;
98
- exposeHeader: true;
99
- generator: () => string;
100
- };
101
- metrics: {
102
- enable: false;
103
- path: string;
104
- withGlobalPrefix: false;
105
- };
106
- serviceVersion: {
107
- enable: false;
108
- headerName: string;
109
- version: string;
110
- };
111
- };
112
- /**
113
- * Update the @catbee/utils configuration.
114
- * @param value Partial configuration object.
115
- */
116
- export declare function setConfig(value: Partial<typeof config>): void;
117
- /**
118
- * Get the current @catbee/utils configuration.
119
- * @returns The current configuration object.
120
- */
121
- export declare function getConfig(): typeof config;
@@ -1,132 +0,0 @@
1
- /*
2
- * The MIT License
3
- *
4
- * Copyright (c) 2025 Catbee Technologies. https://catbee-utils.npm.hprasath.com/license
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
- import { Env } from './utils/env.utils';
25
- import { uuid } from './utils/id.utils';
26
- import { deepObjMerge } from './utils/obj.utils';
27
- /**
28
- * Application runtime configuration loaded from environment variables.
29
- */
30
- export let config = {
31
- logger: {
32
- /**
33
- * Logging level (e.g., 'info', 'debug', 'warn', 'error').
34
- */
35
- level: Env.get('LOGGER_LEVEL', 'info'),
36
- /**
37
- * Name of the logger instance (defaults to npm package name).
38
- */
39
- name: Env.get('LOGGER_NAME', Env.get('npm_package_name', '@catbee/utils')),
40
- /**
41
- * Enables pretty-print logging in development.
42
- * Has no effect in production.
43
- */
44
- pretty: Env.getBoolean('LOGGER_PRETTY', true),
45
- /**
46
- * Single line output for pretty-print (default: false)
47
- */
48
- singleLine: Env.getBoolean('LOGGER_PRETTY_SINGLE_LINE', false)
49
- },
50
- cache: {
51
- /**
52
- * Default TTL (time to live) for cache entries in seconds
53
- */
54
- defaultTtl: Env.getNumber('CACHE_DEFAULT_TTL_SECONDS', 3600) * 1000
55
- }
56
- };
57
- export const defaultServerConfig = {
58
- port: 3000,
59
- host: '0.0.0.0',
60
- cors: false,
61
- helmet: false,
62
- compression: false,
63
- bodyParser: {
64
- json: { limit: '1mb' },
65
- urlencoded: { extended: true, limit: '1mb' }
66
- },
67
- cookieParser: false,
68
- isMicroservice: false,
69
- appName: 'express_app',
70
- globalHeaders: {},
71
- rateLimit: {
72
- enable: false,
73
- windowMs: 15 * 60 * 1000,
74
- max: 100,
75
- message: 'Too many requests',
76
- standardHeaders: true,
77
- legacyHeaders: false
78
- },
79
- requestLogging: {
80
- enable: Env.isDev(),
81
- ignorePaths: (req, _res) => {
82
- const skipPaths = ['/healthz', '/favicon.ico', '/metrics', '/docs', '/.well-known'];
83
- return skipPaths.some(path => req.path.startsWith(path));
84
- },
85
- skipNotFoundRoutes: false
86
- },
87
- openApi: {
88
- enable: false,
89
- mountPath: '/docs',
90
- verbose: false,
91
- withGlobalPrefix: false
92
- },
93
- healthCheck: {
94
- path: '/healthz',
95
- detailed: true
96
- },
97
- requestTimeout: 30000,
98
- responseTime: {
99
- enable: false,
100
- addHeader: true,
101
- logOnComplete: false
102
- },
103
- requestId: {
104
- headerName: 'x-request-id',
105
- exposeHeader: true,
106
- generator: () => uuid()
107
- },
108
- metrics: {
109
- enable: false,
110
- path: '/metrics',
111
- withGlobalPrefix: false
112
- },
113
- serviceVersion: {
114
- enable: false,
115
- headerName: 'x-service-version',
116
- version: '0.0.0'
117
- }
118
- };
119
- /**
120
- * Update the @catbee/utils configuration.
121
- * @param value Partial configuration object.
122
- */
123
- export function setConfig(value) {
124
- deepObjMerge(config, value);
125
- }
126
- /**
127
- * Get the current @catbee/utils configuration.
128
- * @returns The current configuration object.
129
- */
130
- export function getConfig() {
131
- return config;
132
- }
@@ -1,26 +0,0 @@
1
- export { setConfig, getConfig } from './config';
2
- export * from './utils/array.utils';
3
- export * from './utils/async.utils';
4
- export * from './utils/cache.utils';
5
- export * from './utils/context-store.utils';
6
- export * from './utils/crypto.utils';
7
- export * from './utils/decorators.utils';
8
- export * from './utils/dir.utils';
9
- export * from './utils/env.utils';
10
- export * from './utils/exception.utils';
11
- export * from './utils/fs.utils';
12
- export * from './utils/http-status-codes';
13
- export * from './utils/id.utils';
14
- export * from './utils/logger.utils';
15
- export * from './utils/middleware.utils';
16
- export * from './utils/obj.utils';
17
- export * from './utils/request.utils';
18
- export * from './utils/response.utils';
19
- export * from './utils/string.utils';
20
- export * from './utils/url.utils';
21
- export * from './utils/validate.utils';
22
- export * from './types/index';
23
- export * from './types/server';
24
- export * from './types/api-response';
25
- export * from './servers/server';
26
- export * from './servers/server.builder';
@@ -1,49 +0,0 @@
1
- /*
2
- * The MIT License
3
- *
4
- * Copyright (c) 2025 Catbee Technologies. https://catbee-utils.npm.hprasath.com/license
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
- export { setConfig, getConfig } from './config';
25
- export * from './utils/array.utils';
26
- export * from './utils/async.utils';
27
- export * from './utils/cache.utils';
28
- export * from './utils/context-store.utils';
29
- export * from './utils/crypto.utils';
30
- export * from './utils/decorators.utils';
31
- export * from './utils/dir.utils';
32
- export * from './utils/env.utils';
33
- export * from './utils/exception.utils';
34
- export * from './utils/fs.utils';
35
- export * from './utils/http-status-codes';
36
- export * from './utils/id.utils';
37
- export * from './utils/logger.utils';
38
- export * from './utils/middleware.utils';
39
- export * from './utils/obj.utils';
40
- export * from './utils/request.utils';
41
- export * from './utils/response.utils';
42
- export * from './utils/string.utils';
43
- export * from './utils/url.utils';
44
- export * from './utils/validate.utils';
45
- export * from './types/index';
46
- export * from './types/server';
47
- export * from './types/api-response';
48
- export * from './servers/server';
49
- export * from './servers/server.builder';