elseware-nodejs 1.11.1 → 1.11.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/dist/index.d.cts CHANGED
@@ -1,13 +1,68 @@
1
+ import { ZodTypeAny, infer, ZodSchema } from 'zod';
1
2
  import { CorsOptions } from 'cors';
2
3
  import * as express from 'express';
3
4
  import { Request, Response, NextFunction, RequestHandler } from 'express';
4
5
  import * as qs from 'qs';
5
6
  import * as express_serve_static_core from 'express-serve-static-core';
6
7
  import { Schema } from 'joi';
7
- import { ZodSchema } from 'zod';
8
8
  import { Model, UpdateQuery } from 'mongoose';
9
9
  import { SignOptions, JwtPayload } from 'jsonwebtoken';
10
10
 
11
+ declare const DEFAULT_ALLOWED_ORIGINS: string[];
12
+
13
+ interface LoadEnvOptions<TSchema extends ZodTypeAny, TTransform = undefined> {
14
+ schema: TSchema;
15
+ transform?: (env: infer<TSchema>) => TTransform;
16
+ }
17
+
18
+ declare function loadEnv<TSchema extends ZodTypeAny, TTransform = undefined>(options: LoadEnvOptions<TSchema, TTransform>): TTransform extends undefined ? infer<TSchema> : TTransform;
19
+
20
+ interface AppErrorOptions {
21
+ code?: string;
22
+ details?: Record<string, unknown>;
23
+ isOperational?: boolean;
24
+ }
25
+ declare class AppError extends Error {
26
+ readonly statusCode: number;
27
+ readonly status: string;
28
+ readonly isOperational: boolean;
29
+ readonly code?: string;
30
+ readonly details?: Record<string, unknown>;
31
+ constructor(message: string, statusCode?: number, options?: AppErrorOptions);
32
+ }
33
+
34
+ declare enum LoggerLevel {
35
+ DEBUG = "DEBUG",
36
+ INFO = "INFO",
37
+ WARN = "WARN",
38
+ ERROR = "ERROR"
39
+ }
40
+
41
+ interface LoggerOptions {
42
+ enabled?: boolean;
43
+ timestamp?: boolean;
44
+ colors?: boolean;
45
+ level?: LoggerLevel;
46
+ }
47
+
48
+ declare class Logger {
49
+ private enabled;
50
+ private timestamp;
51
+ private colorsEnabled;
52
+ private minimumLevel;
53
+ configure(options?: LoggerOptions): void;
54
+ private levelWeight;
55
+ private shouldLog;
56
+ private formatLevel;
57
+ private write;
58
+ debug(message: string): void;
59
+ info(message: string): void;
60
+ warn(message: string): void;
61
+ error(message: string, error?: unknown): void;
62
+ }
63
+
64
+ declare const logger: Logger;
65
+
11
66
  /**
12
67
  * CircularArray (Ring Buffer)
13
68
  * ---------------------------
@@ -2281,4 +2336,4 @@ declare function toMinutes(ms: number): number;
2281
2336
  declare function toHours(ms: number): number;
2282
2337
  declare function sleep(ms: number): Promise<void>;
2283
2338
 
2284
- export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AsyncHandler, type AsyncRequestHandler, type AuthStrategy, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CorrelationId, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, type DatabaseConnectionOptions, DatabaseManager, type DatabaseProvider, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, type ErrorMeta, ErrorMiddleware, type ExponentialBackoffOptions, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, type Filter, FixedRetryPolicy, type FixedRetryPolicyOptions, Graph, HashMap, HashSet, HttpClient, type HttpClientOptions, HyperLogLog, type IValidator, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, MaxHeap, MaxStack, MinHeap, MinStack, type MongoDatabaseConfig, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, type PaginationMeta, type PaginationQuery, PairingHeap, PairingNode, type ParsedQuery, type PickOptions, type Point, type Point2D, PriorityQueue, type ProgressCallback, QUERY_RESERVED_FIELDS, QuadTree, type QueryFilter, type QueryOperator, type QueryOptions, type QuerySort, Queue, RadixTree, type Rect, RedBlackTree, type Repository, RequestContext, type RequestContextData, type RequestContextOptions, type RetryPolicy, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, type Select, type SendEmailOptions, ServiceClient, type ServiceResponse, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, type TokenProvider, TracingHeaders, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createAllowedOrigins, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isJoiSchema, isZodSchema, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
2339
+ export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, type AppErrorOptions, AsyncHandler, type AsyncRequestHandler, type AuthStrategy, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CorrelationId, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, DEFAULT_ALLOWED_ORIGINS, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, type DatabaseConnectionOptions, DatabaseManager, type DatabaseProvider, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, type ErrorMeta, ErrorMiddleware, type ExponentialBackoffOptions, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, type Filter, FixedRetryPolicy, type FixedRetryPolicyOptions, Graph, HashMap, HashSet, HttpClient, type HttpClientOptions, HyperLogLog, type IValidator, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, type LoadEnvOptions, Logger, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, type MongoDatabaseConfig, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, type PaginationMeta, type PaginationQuery, PairingHeap, PairingNode, type ParsedQuery, type PickOptions, type Point, type Point2D, PriorityQueue, type ProgressCallback, QUERY_RESERVED_FIELDS, QuadTree, type QueryFilter, type QueryOperator, type QueryOptions, type QuerySort, Queue, RadixTree, type Rect, RedBlackTree, type Repository, RequestContext, type RequestContextData, type RequestContextOptions, type RetryPolicy, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, type Select, type SendEmailOptions, ServiceClient, type ServiceResponse, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, type TokenProvider, TracingHeaders, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createAllowedOrigins, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,68 @@
1
+ import { ZodTypeAny, infer, ZodSchema } from 'zod';
1
2
  import { CorsOptions } from 'cors';
2
3
  import * as express from 'express';
3
4
  import { Request, Response, NextFunction, RequestHandler } from 'express';
4
5
  import * as qs from 'qs';
5
6
  import * as express_serve_static_core from 'express-serve-static-core';
6
7
  import { Schema } from 'joi';
7
- import { ZodSchema } from 'zod';
8
8
  import { Model, UpdateQuery } from 'mongoose';
9
9
  import { SignOptions, JwtPayload } from 'jsonwebtoken';
10
10
 
11
+ declare const DEFAULT_ALLOWED_ORIGINS: string[];
12
+
13
+ interface LoadEnvOptions<TSchema extends ZodTypeAny, TTransform = undefined> {
14
+ schema: TSchema;
15
+ transform?: (env: infer<TSchema>) => TTransform;
16
+ }
17
+
18
+ declare function loadEnv<TSchema extends ZodTypeAny, TTransform = undefined>(options: LoadEnvOptions<TSchema, TTransform>): TTransform extends undefined ? infer<TSchema> : TTransform;
19
+
20
+ interface AppErrorOptions {
21
+ code?: string;
22
+ details?: Record<string, unknown>;
23
+ isOperational?: boolean;
24
+ }
25
+ declare class AppError extends Error {
26
+ readonly statusCode: number;
27
+ readonly status: string;
28
+ readonly isOperational: boolean;
29
+ readonly code?: string;
30
+ readonly details?: Record<string, unknown>;
31
+ constructor(message: string, statusCode?: number, options?: AppErrorOptions);
32
+ }
33
+
34
+ declare enum LoggerLevel {
35
+ DEBUG = "DEBUG",
36
+ INFO = "INFO",
37
+ WARN = "WARN",
38
+ ERROR = "ERROR"
39
+ }
40
+
41
+ interface LoggerOptions {
42
+ enabled?: boolean;
43
+ timestamp?: boolean;
44
+ colors?: boolean;
45
+ level?: LoggerLevel;
46
+ }
47
+
48
+ declare class Logger {
49
+ private enabled;
50
+ private timestamp;
51
+ private colorsEnabled;
52
+ private minimumLevel;
53
+ configure(options?: LoggerOptions): void;
54
+ private levelWeight;
55
+ private shouldLog;
56
+ private formatLevel;
57
+ private write;
58
+ debug(message: string): void;
59
+ info(message: string): void;
60
+ warn(message: string): void;
61
+ error(message: string, error?: unknown): void;
62
+ }
63
+
64
+ declare const logger: Logger;
65
+
11
66
  /**
12
67
  * CircularArray (Ring Buffer)
13
68
  * ---------------------------
@@ -2281,4 +2336,4 @@ declare function toMinutes(ms: number): number;
2281
2336
  declare function toHours(ms: number): number;
2282
2337
  declare function sleep(ms: number): Promise<void>;
2283
2338
 
2284
- export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AsyncHandler, type AsyncRequestHandler, type AuthStrategy, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CorrelationId, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, type DatabaseConnectionOptions, DatabaseManager, type DatabaseProvider, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, type ErrorMeta, ErrorMiddleware, type ExponentialBackoffOptions, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, type Filter, FixedRetryPolicy, type FixedRetryPolicyOptions, Graph, HashMap, HashSet, HttpClient, type HttpClientOptions, HyperLogLog, type IValidator, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, MaxHeap, MaxStack, MinHeap, MinStack, type MongoDatabaseConfig, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, type PaginationMeta, type PaginationQuery, PairingHeap, PairingNode, type ParsedQuery, type PickOptions, type Point, type Point2D, PriorityQueue, type ProgressCallback, QUERY_RESERVED_FIELDS, QuadTree, type QueryFilter, type QueryOperator, type QueryOptions, type QuerySort, Queue, RadixTree, type Rect, RedBlackTree, type Repository, RequestContext, type RequestContextData, type RequestContextOptions, type RetryPolicy, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, type Select, type SendEmailOptions, ServiceClient, type ServiceResponse, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, type TokenProvider, TracingHeaders, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createAllowedOrigins, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isJoiSchema, isZodSchema, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
2339
+ export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, type AppErrorOptions, AsyncHandler, type AsyncRequestHandler, type AuthStrategy, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CorrelationId, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, DEFAULT_ALLOWED_ORIGINS, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, type DatabaseConnectionOptions, DatabaseManager, type DatabaseProvider, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, type ErrorMeta, ErrorMiddleware, type ExponentialBackoffOptions, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, type Filter, FixedRetryPolicy, type FixedRetryPolicyOptions, Graph, HashMap, HashSet, HttpClient, type HttpClientOptions, HyperLogLog, type IValidator, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, type LoadEnvOptions, Logger, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, type MongoDatabaseConfig, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, type PaginationMeta, type PaginationQuery, PairingHeap, PairingNode, type ParsedQuery, type PickOptions, type Point, type Point2D, PriorityQueue, type ProgressCallback, QUERY_RESERVED_FIELDS, QuadTree, type QueryFilter, type QueryOperator, type QueryOptions, type QuerySort, Queue, RadixTree, type Rect, RedBlackTree, type Repository, RequestContext, type RequestContextData, type RequestContextOptions, type RetryPolicy, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, type Select, type SendEmailOptions, ServiceClient, type ServiceResponse, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, type TokenProvider, TracingHeaders, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createAllowedOrigins, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import dotenv from 'dotenv';
1
2
  import mongoose from 'mongoose';
2
3
  import { randomUUID } from 'crypto';
3
4
  import { AsyncLocalStorage } from 'async_hooks';
@@ -11,6 +12,160 @@ import juice from 'juice';
11
12
  import jwt from 'jsonwebtoken';
12
13
  import multer from 'multer';
13
14
 
15
+ // src/core/constants/defaultOrigins.ts
16
+ var DEFAULT_ALLOWED_ORIGINS = ["http://localhost:3000"];
17
+
18
+ // src/utils/errorToString.ts
19
+ function errorToString(error) {
20
+ if (error instanceof Error) {
21
+ return `${error.name}: ${error.message}
22
+ ${error.stack ?? ""}`;
23
+ }
24
+ if (typeof error === "object") {
25
+ try {
26
+ return JSON.stringify(error, null, 2);
27
+ } catch {
28
+ return "[Unserializable object]";
29
+ }
30
+ }
31
+ return String(error);
32
+ }
33
+
34
+ // src/core/logger/colors.ts
35
+ var colors = {
36
+ reset: "\x1B[0m",
37
+ blue: "\x1B[34m",
38
+ yellow: "\x1B[33m",
39
+ red: "\x1B[31m",
40
+ cyan: "\x1B[36m"
41
+ };
42
+
43
+ // src/core/logger/Logger.ts
44
+ var Logger = class {
45
+ enabled = true;
46
+ timestamp = true;
47
+ colorsEnabled = true;
48
+ minimumLevel = "INFO" /* INFO */;
49
+ configure(options = {}) {
50
+ this.enabled = options.enabled ?? this.enabled;
51
+ this.timestamp = options.timestamp ?? this.timestamp;
52
+ this.colorsEnabled = options.colors ?? this.colorsEnabled;
53
+ this.minimumLevel = options.level ?? this.minimumLevel;
54
+ }
55
+ levelWeight(level) {
56
+ switch (level) {
57
+ case "DEBUG" /* DEBUG */:
58
+ return 10;
59
+ case "INFO" /* INFO */:
60
+ return 20;
61
+ case "WARN" /* WARN */:
62
+ return 30;
63
+ case "ERROR" /* ERROR */:
64
+ return 40;
65
+ }
66
+ }
67
+ shouldLog(level) {
68
+ return this.levelWeight(level) >= this.levelWeight(this.minimumLevel);
69
+ }
70
+ formatLevel(level) {
71
+ if (!this.colorsEnabled) {
72
+ return level;
73
+ }
74
+ switch (level) {
75
+ case "DEBUG" /* DEBUG */:
76
+ return `${colors.cyan}${level}${colors.reset}`;
77
+ case "INFO" /* INFO */:
78
+ return `${colors.blue}${level}${colors.reset}`;
79
+ case "WARN" /* WARN */:
80
+ return `${colors.yellow}${level}${colors.reset}`;
81
+ case "ERROR" /* ERROR */:
82
+ return `${colors.red}${level}${colors.reset}`;
83
+ }
84
+ }
85
+ write(level, message) {
86
+ if (!this.enabled) {
87
+ return;
88
+ }
89
+ if (!this.shouldLog(level)) {
90
+ return;
91
+ }
92
+ const timestamp = this.timestamp ? `[${(/* @__PURE__ */ new Date()).toISOString()}] ` : "";
93
+ console.log(`${timestamp}[${this.formatLevel(level)}] ${message}`);
94
+ }
95
+ debug(message) {
96
+ this.write("DEBUG" /* DEBUG */, message);
97
+ }
98
+ info(message) {
99
+ this.write("INFO" /* INFO */, message);
100
+ }
101
+ warn(message) {
102
+ this.write("WARN" /* WARN */, message);
103
+ }
104
+ error(message, error) {
105
+ if (error) {
106
+ this.write("ERROR" /* ERROR */, `${message}
107
+ ${errorToString(error)}`);
108
+ return;
109
+ }
110
+ this.write("ERROR" /* ERROR */, message);
111
+ }
112
+ };
113
+
114
+ // src/core/logger/index.ts
115
+ var logger = new Logger();
116
+
117
+ // src/core/environment/loadEnv.ts
118
+ dotenv.config({ quiet: true });
119
+ function loadEnv(options) {
120
+ const result = options.schema.safeParse(process.env);
121
+ if (!result.success) {
122
+ handleValidationError(result.error);
123
+ }
124
+ logger.info("Environment variables validated");
125
+ const env = result.data;
126
+ return options.transform ? options.transform(env) : env;
127
+ }
128
+ function handleValidationError(error) {
129
+ logger.error("Environment validation failed");
130
+ const grouped = {};
131
+ error.issues.forEach((issue) => {
132
+ const key = issue.path.join(".") || "unknown";
133
+ const rawValue = key !== "unknown" ? process.env[key] : void 0;
134
+ const safeValue = key.toLowerCase().includes("secret") ? "***" : rawValue;
135
+ const message = [
136
+ `message: ${issue.message}`,
137
+ `code: ${issue.code}`,
138
+ rawValue !== void 0 ? `value: ${JSON.stringify(safeValue)}` : null
139
+ ].filter(Boolean).join(" | ");
140
+ grouped[key] ??= [];
141
+ grouped[key].push(message);
142
+ });
143
+ Object.entries(grouped).forEach(([key, messages]) => {
144
+ logger.error(`ENV: ${key}`);
145
+ messages.forEach((message) => logger.error(` - ${message}`));
146
+ });
147
+ logger.error("Application startup aborted");
148
+ process.exit(1);
149
+ }
150
+
151
+ // src/core/errors/AppError.ts
152
+ var AppError = class extends Error {
153
+ statusCode;
154
+ status;
155
+ isOperational;
156
+ code;
157
+ details;
158
+ constructor(message, statusCode = 500, options) {
159
+ super(message);
160
+ this.statusCode = statusCode;
161
+ this.status = statusCode >= 400 && statusCode < 500 ? "fail" : "error";
162
+ this.isOperational = options?.isOperational ?? true;
163
+ this.code = options?.code;
164
+ this.details = options?.details;
165
+ Error.captureStackTrace(this, this.constructor);
166
+ }
167
+ };
168
+
14
169
  // src/data-structures/array/CircularArray.ts
15
170
  var CircularArray = class {
16
171
  capacity;
@@ -4693,9 +4848,6 @@ var SegmentTree = class {
4693
4848
  }
4694
4849
  };
4695
4850
 
4696
- // src/core/constants/defaultOrigins.ts
4697
- var DEFAULT_ALLOWED_ORIGINS = ["http://localhost:3000"];
4698
-
4699
4851
  // src/infrastructure/cors/createAllowedOrigins.ts
4700
4852
  function createAllowedOrigins(options = {}) {
4701
4853
  const { origins, defaults = DEFAULT_ALLOWED_ORIGINS } = options;
@@ -4734,105 +4886,6 @@ function createCorsOptions(allowedOrigins) {
4734
4886
  };
4735
4887
  }
4736
4888
 
4737
- // src/utils/errorToString.ts
4738
- function errorToString(error) {
4739
- if (error instanceof Error) {
4740
- return `${error.name}: ${error.message}
4741
- ${error.stack ?? ""}`;
4742
- }
4743
- if (typeof error === "object") {
4744
- try {
4745
- return JSON.stringify(error, null, 2);
4746
- } catch {
4747
- return "[Unserializable object]";
4748
- }
4749
- }
4750
- return String(error);
4751
- }
4752
-
4753
- // src/core/logger/colors.ts
4754
- var colors = {
4755
- reset: "\x1B[0m",
4756
- blue: "\x1B[34m",
4757
- yellow: "\x1B[33m",
4758
- red: "\x1B[31m",
4759
- cyan: "\x1B[36m"
4760
- };
4761
-
4762
- // src/core/logger/Logger.ts
4763
- var Logger = class {
4764
- enabled = true;
4765
- timestamp = true;
4766
- colorsEnabled = true;
4767
- minimumLevel = "INFO" /* INFO */;
4768
- configure(options = {}) {
4769
- this.enabled = options.enabled ?? this.enabled;
4770
- this.timestamp = options.timestamp ?? this.timestamp;
4771
- this.colorsEnabled = options.colors ?? this.colorsEnabled;
4772
- this.minimumLevel = options.level ?? this.minimumLevel;
4773
- }
4774
- levelWeight(level) {
4775
- switch (level) {
4776
- case "DEBUG" /* DEBUG */:
4777
- return 10;
4778
- case "INFO" /* INFO */:
4779
- return 20;
4780
- case "WARN" /* WARN */:
4781
- return 30;
4782
- case "ERROR" /* ERROR */:
4783
- return 40;
4784
- }
4785
- }
4786
- shouldLog(level) {
4787
- return this.levelWeight(level) >= this.levelWeight(this.minimumLevel);
4788
- }
4789
- formatLevel(level) {
4790
- if (!this.colorsEnabled) {
4791
- return level;
4792
- }
4793
- switch (level) {
4794
- case "DEBUG" /* DEBUG */:
4795
- return `${colors.cyan}${level}${colors.reset}`;
4796
- case "INFO" /* INFO */:
4797
- return `${colors.blue}${level}${colors.reset}`;
4798
- case "WARN" /* WARN */:
4799
- return `${colors.yellow}${level}${colors.reset}`;
4800
- case "ERROR" /* ERROR */:
4801
- return `${colors.red}${level}${colors.reset}`;
4802
- }
4803
- }
4804
- write(level, message) {
4805
- if (!this.enabled) {
4806
- return;
4807
- }
4808
- if (!this.shouldLog(level)) {
4809
- return;
4810
- }
4811
- const timestamp = this.timestamp ? `[${(/* @__PURE__ */ new Date()).toISOString()}] ` : "";
4812
- console.log(`${timestamp}[${this.formatLevel(level)}] ${message}`);
4813
- }
4814
- debug(message) {
4815
- this.write("DEBUG" /* DEBUG */, message);
4816
- }
4817
- info(message) {
4818
- this.write("INFO" /* INFO */, message);
4819
- }
4820
- warn(message) {
4821
- this.write("WARN" /* WARN */, message);
4822
- }
4823
- error(message, error) {
4824
- if (error) {
4825
- this.write("ERROR" /* ERROR */, `${message}
4826
- ${errorToString(error)}`);
4827
- return;
4828
- }
4829
- this.write("ERROR" /* ERROR */, message);
4830
- }
4831
- };
4832
-
4833
- // src/core/logger/index.ts
4834
- var logger = new Logger();
4835
-
4836
4889
  // src/infrastructure/database/DatabaseManager.ts
4837
4890
  var DatabaseManager = class {
4838
4891
  constructor(provider, options = {
@@ -4917,24 +4970,6 @@ var MongoDatabaseProvider = class {
4917
4970
  }
4918
4971
  };
4919
4972
 
4920
- // src/core/errors/AppError.ts
4921
- var AppError = class extends Error {
4922
- statusCode;
4923
- status;
4924
- isOperational;
4925
- code;
4926
- details;
4927
- constructor(message, statusCode = 500, options) {
4928
- super(message);
4929
- this.statusCode = statusCode;
4930
- this.status = statusCode >= 400 && statusCode < 500 ? "fail" : "error";
4931
- this.isOperational = options?.isOperational ?? true;
4932
- this.code = options?.code;
4933
- this.details = options?.details;
4934
- Error.captureStackTrace(this, this.constructor);
4935
- }
4936
- };
4937
-
4938
4973
  // src/infrastructure/http/handlers/AsyncHandler.ts
4939
4974
  var AsyncHandler = (fn) => (req, res, next) => {
4940
4975
  Promise.resolve(fn(req, res, next)).catch(next);
@@ -5234,7 +5269,7 @@ var handleDuplicateKey = (err) => {
5234
5269
  code: "DUPLICATE_FIELD"
5235
5270
  });
5236
5271
  };
5237
- var handleValidationError = (err) => {
5272
+ var handleValidationError2 = (err) => {
5238
5273
  const errors = Object.entries(err.errors).reduce(
5239
5274
  (acc, [key, value]) => {
5240
5275
  acc[key] = value.message;
@@ -5271,7 +5306,7 @@ var ErrorMiddleware = (isProduction = false) => (err, _req, res, _next) => {
5271
5306
  );
5272
5307
  }
5273
5308
  if (err && err.name === "ValidationError") {
5274
- error = handleValidationError(err);
5309
+ error = handleValidationError2(err);
5275
5310
  }
5276
5311
  if (err?.name === "JsonWebTokenError") {
5277
5312
  error = handleJWTError();
@@ -6285,6 +6320,6 @@ function sleep(ms) {
6285
6320
  return new Promise((resolve) => setTimeout(resolve, ms));
6286
6321
  }
6287
6322
 
6288
- export { AVLTree, AdjacencyList, AdjacencyMatrix, ApiFeatures, ApiResponse, AsyncHandler, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, CloudinaryService, ConsistentHash, CorrelationId, CountMinSketch, CrudControllerFactory, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, DatabaseManager, Deque, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, EmailService, ErrorMiddleware, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, FixedRetryPolicy, Graph, HashMap, HashSet, HttpClient, HyperLogLog, InternalServiceClient, IntervalTree, JWTService, JoiValidator, KDTree, LFUCache, LRUCache, MaxHeap, MaxStack, MinHeap, MinStack, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, PriorityQueue, QUERY_RESERVED_FIELDS, QuadTree, Queue, RadixTree, RedBlackTree, RequestContext, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, ServiceClient, Set2 as Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TracingHeaders, TreeNode, Trie, ZodValidator, authMiddleware, createAllowedOrigins, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isJoiSchema, isZodSchema, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
6323
+ export { AVLTree, AdjacencyList, AdjacencyMatrix, ApiFeatures, ApiResponse, AppError, AsyncHandler, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, CloudinaryService, ConsistentHash, CorrelationId, CountMinSketch, CrudControllerFactory, DEFAULT_ALLOWED_ORIGINS, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, DatabaseManager, Deque, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, EmailService, ErrorMiddleware, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, FixedRetryPolicy, Graph, HashMap, HashSet, HttpClient, HyperLogLog, InternalServiceClient, IntervalTree, JWTService, JoiValidator, KDTree, LFUCache, LRUCache, Logger, MaxHeap, MaxStack, MinHeap, MinStack, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, PriorityQueue, QUERY_RESERVED_FIELDS, QuadTree, Queue, RadixTree, RedBlackTree, RequestContext, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, ServiceClient, Set2 as Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TracingHeaders, TreeNode, Trie, ZodValidator, authMiddleware, createAllowedOrigins, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
6289
6324
  //# sourceMappingURL=index.js.map
6290
6325
  //# sourceMappingURL=index.js.map