@navios/core 1.1.0 → 2.0.0-alpha.1

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 (237) hide show
  1. package/CHANGELOG.md +85 -13
  2. package/README.md +69 -220
  3. package/lib/async-context-BAdt7bno.d.mts +239 -0
  4. package/lib/async-context-BAdt7bno.d.mts.map +1 -0
  5. package/lib/async-context-RsWmy2Hi.d.cts +239 -0
  6. package/lib/async-context-RsWmy2Hi.d.cts.map +1 -0
  7. package/lib/attribute-factory-BW1kgBqf.d.mts +70 -0
  8. package/lib/attribute-factory-BW1kgBqf.d.mts.map +1 -0
  9. package/lib/attribute-factory-DqN4x5XM.d.cts +70 -0
  10. package/lib/attribute-factory-DqN4x5XM.d.cts.map +1 -0
  11. package/lib/attribute-value-BNiJjxl1.mjs +225 -0
  12. package/lib/attribute-value-BNiJjxl1.mjs.map +1 -0
  13. package/lib/attribute-value-Cux5HhOL.cjs +314 -0
  14. package/lib/attribute-value-Cux5HhOL.cjs.map +1 -0
  15. package/lib/basic-execution-context-5uq2DvEA.cjs +318 -0
  16. package/lib/basic-execution-context-5uq2DvEA.cjs.map +1 -0
  17. package/lib/basic-execution-context-u1VktGoM.mjs +277 -0
  18. package/lib/basic-execution-context-u1VktGoM.mjs.map +1 -0
  19. package/lib/execution-context-BVSmLkYp.d.cts +71 -0
  20. package/lib/execution-context-BVSmLkYp.d.cts.map +1 -0
  21. package/lib/execution-context-C5F9rojO.d.mts +71 -0
  22. package/lib/execution-context-C5F9rojO.d.mts.map +1 -0
  23. package/lib/execution-context-token--cKS4cJv.cjs +270 -0
  24. package/lib/execution-context-token--cKS4cJv.cjs.map +1 -0
  25. package/lib/execution-context-token-Cb3M3Ao0.mjs +223 -0
  26. package/lib/execution-context-token-Cb3M3Ao0.mjs.map +1 -0
  27. package/lib/index.cjs +1672 -4426
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +842 -3
  30. package/lib/index.d.cts.map +1 -0
  31. package/lib/index.d.mts +842 -3
  32. package/lib/index.d.mts.map +1 -0
  33. package/lib/index.mjs +1559 -4221
  34. package/lib/index.mjs.map +1 -1
  35. package/lib/legacy-compat/index.cjs +72 -371
  36. package/lib/legacy-compat/index.cjs.map +1 -1
  37. package/lib/legacy-compat/index.d.cts +42 -382
  38. package/lib/legacy-compat/index.d.cts.map +1 -1
  39. package/lib/legacy-compat/index.d.mts +41 -382
  40. package/lib/legacy-compat/index.d.mts.map +1 -1
  41. package/lib/legacy-compat/index.mjs +51 -345
  42. package/lib/legacy-compat/index.mjs.map +1 -1
  43. package/lib/module-Bz83ZnJ5.cjs +173 -0
  44. package/lib/module-Bz83ZnJ5.cjs.map +1 -0
  45. package/lib/module-options-CSqQUSTm.d.mts +51 -0
  46. package/lib/module-options-CSqQUSTm.d.mts.map +1 -0
  47. package/lib/module-options-DSRBri4J.d.cts +51 -0
  48. package/lib/module-options-DSRBri4J.d.cts.map +1 -0
  49. package/lib/module-zPXwR2qp.mjs +138 -0
  50. package/lib/module-zPXwR2qp.mjs.map +1 -0
  51. package/lib/settled-within-B6gpu2XW.cjs +32 -0
  52. package/lib/settled-within-B6gpu2XW.cjs.map +1 -0
  53. package/lib/settled-within-Bc2pj8WB.mjs +21 -0
  54. package/lib/settled-within-Bc2pj8WB.mjs.map +1 -0
  55. package/lib/testing/index.cjs +74 -414
  56. package/lib/testing/index.cjs.map +1 -1
  57. package/lib/testing/index.d.cts +25 -385
  58. package/lib/testing/index.d.cts.map +1 -1
  59. package/lib/testing/index.d.mts +24 -385
  60. package/lib/testing/index.d.mts.map +1 -1
  61. package/lib/testing/index.mjs +72 -408
  62. package/lib/testing/index.mjs.map +1 -1
  63. package/lib/transport.cjs +36 -0
  64. package/lib/transport.d.cts +254 -0
  65. package/lib/transport.d.cts.map +1 -0
  66. package/lib/transport.d.mts +254 -0
  67. package/lib/transport.d.mts.map +1 -0
  68. package/lib/transport.mjs +6 -0
  69. package/package.json +37 -17
  70. package/docs/README.md +0 -316
  71. package/docs/adapters.md +0 -308
  72. package/docs/application-setup.md +0 -524
  73. package/docs/attributes.md +0 -689
  74. package/docs/controllers.md +0 -373
  75. package/docs/endpoints.md +0 -444
  76. package/docs/exceptions.md +0 -352
  77. package/docs/guards.md +0 -550
  78. package/docs/legacy-compat.md +0 -356
  79. package/docs/modules.md +0 -377
  80. package/docs/quick-start.md +0 -290
  81. package/docs/services.md +0 -427
  82. package/docs/testing.md +0 -827
  83. package/lib/index-3LcTrbxz.d.mts +0 -3804
  84. package/lib/index-3LcTrbxz.d.mts.map +0 -1
  85. package/lib/index-B14SekVb.d.cts +0 -3804
  86. package/lib/index-B14SekVb.d.cts.map +0 -1
  87. package/lib/navios.factory-CUrO_p6K.cjs +0 -4538
  88. package/lib/navios.factory-CUrO_p6K.cjs.map +0 -1
  89. package/lib/navios.factory-DjUOOVVL.mjs +0 -4151
  90. package/lib/navios.factory-DjUOOVVL.mjs.map +0 -1
  91. package/lib/tokens-BEuBMGGX.cjs +0 -193
  92. package/lib/tokens-BEuBMGGX.cjs.map +0 -1
  93. package/lib/tokens-COyNGV1I.mjs +0 -97
  94. package/lib/tokens-COyNGV1I.mjs.map +0 -1
  95. package/lib/use-guards.decorator-DLmRl2CV.mjs +0 -336
  96. package/lib/use-guards.decorator-DLmRl2CV.mjs.map +0 -1
  97. package/lib/use-guards.decorator-DhumFTk3.cjs +0 -444
  98. package/lib/use-guards.decorator-DhumFTk3.cjs.map +0 -1
  99. package/project.json +0 -66
  100. package/src/__tests__/attribute.factory.spec.mts +0 -300
  101. package/src/__tests__/config.service.spec.mts +0 -43
  102. package/src/__tests__/console-logger.service.spec.mts +0 -312
  103. package/src/__tests__/controller-resolver.spec.mts +0 -229
  104. package/src/__tests__/controller.spec.mts +0 -58
  105. package/src/__tests__/guard-runner.service.spec.mts +0 -399
  106. package/src/__tests__/logger.service.spec.mts +0 -147
  107. package/src/__tests__/responders.spec.mts +0 -340
  108. package/src/__tests__/testing-module.spec.mts +0 -459
  109. package/src/__tests__/unit-testing-module.spec.mts +0 -424
  110. package/src/attribute.factory.mts +0 -325
  111. package/src/config/config-service.interface.mts +0 -47
  112. package/src/config/config.provider.mts +0 -69
  113. package/src/config/config.service.mts +0 -176
  114. package/src/config/index.mts +0 -5
  115. package/src/config/types.mts +0 -58
  116. package/src/config/utils/helpers.mts +0 -23
  117. package/src/config/utils/index.mts +0 -1
  118. package/src/decorators/controller.decorator.mts +0 -81
  119. package/src/decorators/endpoint.decorator.mts +0 -181
  120. package/src/decorators/header.decorator.mts +0 -38
  121. package/src/decorators/http-code.decorator.mts +0 -38
  122. package/src/decorators/index.mts +0 -8
  123. package/src/decorators/module.decorator.mts +0 -106
  124. package/src/decorators/multipart.decorator.mts +0 -169
  125. package/src/decorators/stream.decorator.mts +0 -155
  126. package/src/decorators/use-guards.decorator.mts +0 -73
  127. package/src/exceptions/bad-request.exception.mts +0 -28
  128. package/src/exceptions/conflict.exception.mts +0 -31
  129. package/src/exceptions/forbidden.exception.mts +0 -30
  130. package/src/exceptions/http.exception.mts +0 -33
  131. package/src/exceptions/index.mts +0 -7
  132. package/src/exceptions/internal-server-error.exception.mts +0 -33
  133. package/src/exceptions/not-found.exception.mts +0 -33
  134. package/src/exceptions/unauthorized.exception.mts +0 -30
  135. package/src/factories/adapter.factory.mts +0 -20
  136. package/src/factories/endpoint-adapter.factory.mts +0 -21
  137. package/src/factories/http-adapter.factory.mts +0 -20
  138. package/src/factories/index.mts +0 -8
  139. package/src/factories/multipart-adapter.factory.mts +0 -21
  140. package/src/factories/reply.factory.mts +0 -21
  141. package/src/factories/request.factory.mts +0 -21
  142. package/src/factories/stream-adapter.factory.mts +0 -20
  143. package/src/factories/xml-stream-adapter.factory.mts +0 -20
  144. package/src/index.mts +0 -16
  145. package/src/interfaces/abstract-adapter.interface.mts +0 -32
  146. package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
  147. package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
  148. package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
  149. package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
  150. package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
  151. package/src/interfaces/adapter-environment.interface.mts +0 -74
  152. package/src/interfaces/can-activate.mts +0 -38
  153. package/src/interfaces/http-header.mts +0 -18
  154. package/src/interfaces/index.mts +0 -14
  155. package/src/interfaces/navios-module.mts +0 -28
  156. package/src/interfaces/plugin-context.mts +0 -104
  157. package/src/interfaces/plugin-stage.mts +0 -62
  158. package/src/interfaces/plugin.interface.mts +0 -119
  159. package/src/interfaces/staged-plugin.interface.mts +0 -209
  160. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
  161. package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
  162. package/src/legacy-compat/attribute.factory.mts +0 -351
  163. package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
  164. package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
  165. package/src/legacy-compat/decorators/header.decorator.mts +0 -43
  166. package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
  167. package/src/legacy-compat/decorators/index.mts +0 -11
  168. package/src/legacy-compat/decorators/module.decorator.mts +0 -37
  169. package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
  170. package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
  171. package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
  172. package/src/legacy-compat/index.mts +0 -57
  173. package/src/logger/README.md +0 -3
  174. package/src/logger/console-logger.service.mts +0 -714
  175. package/src/logger/index.mts +0 -6
  176. package/src/logger/log-levels.mts +0 -21
  177. package/src/logger/logger-service.interface.mts +0 -42
  178. package/src/logger/logger.service.mts +0 -113
  179. package/src/logger/logger.tokens.mts +0 -44
  180. package/src/logger/utils/cli-colors.util.mts +0 -17
  181. package/src/logger/utils/filter-log-levelts.util.mts +0 -29
  182. package/src/logger/utils/index.mts +0 -5
  183. package/src/logger/utils/is-log-level-enabled.mts +0 -33
  184. package/src/logger/utils/is-log-level.util.mts +0 -10
  185. package/src/logger/utils/shared.utils.mts +0 -51
  186. package/src/metadata/controller.metadata.mts +0 -79
  187. package/src/metadata/handler.metadata.mts +0 -80
  188. package/src/metadata/index.mts +0 -4
  189. package/src/metadata/module.metadata.mts +0 -116
  190. package/src/metadata/navios-managed.metadata.mts +0 -42
  191. package/src/navios.application.mts +0 -678
  192. package/src/navios.environment.mts +0 -42
  193. package/src/navios.factory.mts +0 -158
  194. package/src/responders/enums/framework-error.enum.mts +0 -38
  195. package/src/responders/enums/index.mts +0 -1
  196. package/src/responders/index.mts +0 -4
  197. package/src/responders/interfaces/error-responder.interface.mts +0 -42
  198. package/src/responders/interfaces/error-response.interface.mts +0 -22
  199. package/src/responders/interfaces/index.mts +0 -3
  200. package/src/responders/interfaces/problem-details.interface.mts +0 -34
  201. package/src/responders/services/error-response-producer.service.mts +0 -143
  202. package/src/responders/services/forbidden-responder.service.mts +0 -77
  203. package/src/responders/services/index.mts +0 -5
  204. package/src/responders/services/internal-server-error-responder.service.mts +0 -57
  205. package/src/responders/services/not-found-responder.service.mts +0 -76
  206. package/src/responders/services/validation-error-responder.service.mts +0 -78
  207. package/src/responders/tokens/index.mts +0 -1
  208. package/src/responders/tokens/responder.tokens.mts +0 -84
  209. package/src/services/abstract-handler-adapter.service.mts +0 -366
  210. package/src/services/guard-runner.service.mts +0 -152
  211. package/src/services/index.mts +0 -4
  212. package/src/services/instance-resolver.service.mts +0 -177
  213. package/src/services/module-loader.service.mts +0 -255
  214. package/src/stores/index.mts +0 -1
  215. package/src/stores/request-id.store.mts +0 -85
  216. package/src/testing/index.mts +0 -3
  217. package/src/testing/testing-module.mts +0 -393
  218. package/src/testing/unit-testing-module.mts +0 -298
  219. package/src/tokens/adapter.token.mts +0 -6
  220. package/src/tokens/endpoint-adapter.token.mts +0 -8
  221. package/src/tokens/execution-context.token.mts +0 -9
  222. package/src/tokens/http-adapter.token.mts +0 -8
  223. package/src/tokens/index.mts +0 -10
  224. package/src/tokens/multipart-adapter.token.mts +0 -8
  225. package/src/tokens/navios-options.token.mts +0 -6
  226. package/src/tokens/reply.token.mts +0 -3
  227. package/src/tokens/request.token.mts +0 -3
  228. package/src/tokens/stream-adapter.token.mts +0 -8
  229. package/src/tokens/xml-stream-adapter.token.mts +0 -8
  230. package/src/utils/adapter-supports.util.mts +0 -47
  231. package/src/utils/define-plugin.mts +0 -251
  232. package/src/utils/index.mts +0 -2
  233. package/tsconfig.json +0 -21
  234. package/tsconfig.lib.json +0 -8
  235. package/tsconfig.spec.json +0 -15
  236. package/tsdown.config.mts +0 -35
  237. package/vitest.config.mts +0 -15
@@ -1,352 +0,0 @@
1
- # Exception Handling
2
-
3
- Navios provides a comprehensive exception handling system that allows you to throw HTTP exceptions and handle errors in a consistent manner across your application.
4
-
5
- ## Built-in HTTP Exceptions
6
-
7
- Navios includes several built-in HTTP exception classes that correspond to common HTTP status codes:
8
-
9
- ### BadRequestException (400)
10
-
11
- ### UnauthorizedException (401)
12
-
13
- ### ForbiddenException (403)
14
-
15
- ### NotFoundException (404)
16
-
17
- ### ConflictException (409)
18
-
19
- ### InternalServerErrorException (500)
20
-
21
- ## Base HttpException
22
-
23
- All HTTP exceptions extend the base `HttpException` class:
24
-
25
- ```typescript
26
- import { HttpException } from '@navios/core'
27
-
28
- // Create custom exception
29
- export class CustomException extends HttpException {
30
- constructor(message: string) {
31
- super(message, 418) // I'm a teapot
32
- }
33
- }
34
-
35
- // Or throw HttpException directly
36
- @Controller()
37
- export class UserController {
38
- @Endpoint(getUserByIdEndpoint)
39
- async getUserById({ params }: { params: { id: string } }) {
40
- if (!this.isValidId(params.id)) {
41
- throw new HttpException('Invalid user ID format', 422)
42
- }
43
-
44
- return this.userService.findById(params.id)
45
- }
46
- }
47
- ```
48
-
49
- ## Exception with Additional Data
50
-
51
- You can include additional data in exceptions:
52
-
53
- ```typescript
54
- import { BadRequestException } from '@navios/core'
55
-
56
- @Controller()
57
- export class UserController {
58
- @Endpoint(createUserEndpoint)
59
- async createUser({ body }: { body: CreateUserDto }) {
60
- const validationErrors = await this.validateUser(body)
61
-
62
- if (validationErrors.length > 0) {
63
- throw new BadRequestException({
64
- message: 'Validation failed',
65
- errors: validationErrors,
66
- timestamp: new Date().toISOString(),
67
- })
68
- }
69
-
70
- return this.userService.create(body)
71
- }
72
-
73
- private async validateUser(user: CreateUserDto) {
74
- const errors: string[] = []
75
-
76
- if (!user.email) {
77
- errors.push('Email is required')
78
- } else if (!this.isValidEmail(user.email)) {
79
- errors.push('Invalid email format')
80
- }
81
-
82
- if (!user.password || user.password.length < 8) {
83
- errors.push('Password must be at least 8 characters')
84
- }
85
-
86
- return errors
87
- }
88
- }
89
- ```
90
-
91
- ## Custom Exceptions
92
-
93
- Create domain-specific exceptions by extending HTTP exceptions:
94
-
95
- ```typescript
96
- import {
97
- BadRequestException,
98
- ConflictException,
99
- NotFoundException,
100
- } from '@navios/core'
101
-
102
- // Domain-specific exceptions
103
- export class UserNotFoundException extends NotFoundException {
104
- constructor(userId: string) {
105
- super(`User with ID ${userId} not found`)
106
- }
107
- }
108
-
109
- export class InvalidEmailException extends BadRequestException {
110
- constructor(email: string) {
111
- super({
112
- message: 'Invalid email address',
113
- email,
114
- code: 'INVALID_EMAIL',
115
- })
116
- }
117
- }
118
-
119
- export class EmailAlreadyExistsException extends ConflictException {
120
- constructor(email: string) {
121
- super({
122
- message: 'Email address already exists',
123
- email,
124
- code: 'EMAIL_EXISTS',
125
- })
126
- }
127
- }
128
- ```
129
-
130
- ## Async Exception Handling
131
-
132
- Handle exceptions in async operations:
133
-
134
- ```typescript
135
- @Controller()
136
- export class UserController {
137
- private logger = inject(Logger, { context: 'UserController' })
138
-
139
- @Endpoint(sendEmailEndpoint)
140
- async sendEmail({ params }: { params: { id: string } }) {
141
- try {
142
- const user = await this.userService.findById(params.id)
143
-
144
- if (!user) {
145
- throw new NotFoundException(`User with ID ${params.id} not found`)
146
- }
147
-
148
- await this.emailService.sendWelcomeEmail(user.email)
149
-
150
- return { message: 'Email sent successfully' }
151
- } catch (error) {
152
- if (error instanceof HttpException) {
153
- throw error // Re-throw HTTP exceptions
154
- }
155
-
156
- // Log unexpected errors
157
- this.logger.error('Failed to send email', {
158
- userId: params.id,
159
- error: error.message,
160
- stack: error.stack,
161
- })
162
-
163
- throw new InternalServerErrorException('Failed to send email')
164
- }
165
- }
166
- }
167
- ```
168
-
169
- ## Exception Response Format
170
-
171
- ### HttpException Response Format
172
-
173
- `HttpException` and its subclasses (like `NotFoundException`, `BadRequestException`, etc.) maintain backward compatibility and return the original format:
174
-
175
- ```json
176
- {
177
- "statusCode": 404,
178
- "message": "User with ID 123 not found",
179
- "timestamp": "2023-10-01T12:00:00.000Z",
180
- "path": "/users/123"
181
- }
182
- ```
183
-
184
- For exceptions with additional data:
185
-
186
- ```json
187
- {
188
- "statusCode": 400,
189
- "message": "Validation failed",
190
- "errors": [
191
- {
192
- "field": "email",
193
- "message": "Invalid email format",
194
- "code": "INVALID_EMAIL"
195
- }
196
- ],
197
- "timestamp": "2023-10-01T12:00:00.000Z",
198
- "path": "/users"
199
- }
200
- ```
201
-
202
- ### RFC 7807 Problem Details Format
203
-
204
- Framework-level errors (validation errors, guard rejections, not found routes, unhandled errors) use **RFC 7807 Problem Details** format for standardized, machine-readable error responses:
205
-
206
- ```json
207
- {
208
- "type": "about:blank",
209
- "title": "Not Found",
210
- "status": 404,
211
- "detail": "Route [GET] /api/users/999 not found"
212
- }
213
- ```
214
-
215
- Validation errors include structured error details:
216
-
217
- ```json
218
- {
219
- "type": "about:blank",
220
- "title": "Validation Error",
221
- "status": 400,
222
- "detail": "Request validation failed",
223
- "errors": {
224
- "email": {
225
- "code": "invalid_string",
226
- "validation": "email",
227
- "message": "Invalid email",
228
- "path": ["email"]
229
- }
230
- }
231
- }
232
- ```
233
-
234
- All Problem Details responses include the `Content-Type: application/problem+json` header. For more information on customizing error responders, see the [Error Handling Guide](../../../apps/docs/docs/server/guides/error-handling.md).
235
-
236
- ## Best Practices
237
-
238
- ### 1. Use Specific Exceptions
239
-
240
- Use the most specific exception type for better error handling:
241
-
242
- ```typescript
243
- // ✅ Good - Specific exception
244
- if (!user) {
245
- throw new NotFoundException(`User with ID ${id} not found`)
246
- }
247
-
248
- // ❌ Avoid - Generic exception
249
- if (!user) {
250
- throw new HttpException('User not found', 404)
251
- }
252
- ```
253
-
254
- ### 2. Include Context
255
-
256
- Provide helpful context in exception messages:
257
-
258
- ```typescript
259
- // ✅ Good - Includes context
260
- throw new BadRequestException({
261
- message: 'Invalid user data',
262
- field: 'email',
263
- value: email,
264
- reason: 'Email format is invalid',
265
- })
266
-
267
- // ❌ Avoid - Vague message
268
- throw new BadRequestException('Invalid data')
269
- ```
270
-
271
- ### 3. Log Appropriately
272
-
273
- Log exceptions at appropriate levels:
274
-
275
- ```typescript
276
- @Controller()
277
- export class UserController {
278
- private logger = inject(Logger, { context: 'UserController' })
279
-
280
- async getUser(id: string) {
281
- try {
282
- return await this.userService.findById(id)
283
- } catch (error) {
284
- if (error instanceof NotFoundException) {
285
- // Don't log client errors as errors
286
- this.logger.debug(`User not found: ${id}`)
287
- throw error
288
- }
289
-
290
- // Log server errors
291
- this.logger.error('Failed to get user', {
292
- userId: id,
293
- error: error.message,
294
- stack: error.stack,
295
- })
296
-
297
- throw new InternalServerErrorException('Failed to retrieve user')
298
- }
299
- }
300
- }
301
- ```
302
-
303
- ### 4. Don't Expose Internal Details
304
-
305
- Don't expose sensitive information in exception messages:
306
-
307
- ```typescript
308
- // ✅ Good - Safe message
309
- throw new InternalServerErrorException('Database connection failed')
310
-
311
- // ❌ Avoid - Exposes sensitive info
312
- throw new InternalServerErrorException(
313
- `Database connection failed: ${databaseUrl} with credentials ${username}:${password}`,
314
- )
315
- ```
316
-
317
- ### 5. Create Domain-Specific Exceptions
318
-
319
- Create exceptions that match your domain:
320
-
321
- ```typescript
322
- // User domain exceptions
323
- export class UserNotFoundException extends NotFoundException {
324
- constructor(userId: string) {
325
- super(`User with ID ${userId} not found`)
326
- }
327
- }
328
-
329
- export class UserEmailAlreadyExistsException extends ConflictException {
330
- constructor(email: string) {
331
- super(`User with email ${email} already exists`)
332
- }
333
- }
334
-
335
- // Order domain exceptions
336
- export class OrderNotFoundException extends NotFoundException {
337
- constructor(orderId: string) {
338
- super(`Order with ID ${orderId} not found`)
339
- }
340
- }
341
-
342
- export class InsufficientInventoryException extends ConflictException {
343
- constructor(productId: string, requested: number, available: number) {
344
- super({
345
- message: 'Insufficient inventory',
346
- productId,
347
- requested,
348
- available,
349
- })
350
- }
351
- }
352
- ```