@lerianstudio/sindarian-server 1.0.0-beta.9 → 1.1.0

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 (143) hide show
  1. package/README.md +268 -21
  2. package/dist/constants/keys.d.ts +3 -0
  3. package/dist/constants/keys.d.ts.map +1 -1
  4. package/dist/constants/keys.js +4 -1
  5. package/dist/constants/keys.js.map +1 -1
  6. package/dist/controllers/decorators/body-decorator.d.ts +12 -16
  7. package/dist/controllers/decorators/body-decorator.d.ts.map +1 -1
  8. package/dist/controllers/decorators/body-decorator.js +52 -58
  9. package/dist/controllers/decorators/body-decorator.js.map +1 -1
  10. package/dist/controllers/decorators/controller-decorator.d.ts +5 -4
  11. package/dist/controllers/decorators/controller-decorator.d.ts.map +1 -1
  12. package/dist/controllers/decorators/controller-decorator.js +29 -22
  13. package/dist/controllers/decorators/controller-decorator.js.map +1 -1
  14. package/dist/controllers/decorators/param-decorator.d.ts +4 -9
  15. package/dist/controllers/decorators/param-decorator.d.ts.map +1 -1
  16. package/dist/controllers/decorators/param-decorator.js +33 -29
  17. package/dist/controllers/decorators/param-decorator.js.map +1 -1
  18. package/dist/controllers/decorators/query-decorator.d.ts +11 -15
  19. package/dist/controllers/decorators/query-decorator.d.ts.map +1 -1
  20. package/dist/controllers/decorators/query-decorator.js +24 -38
  21. package/dist/controllers/decorators/query-decorator.js.map +1 -1
  22. package/dist/controllers/decorators/request-decorator.d.ts +8 -12
  23. package/dist/controllers/decorators/request-decorator.d.ts.map +1 -1
  24. package/dist/controllers/decorators/request-decorator.js +21 -17
  25. package/dist/controllers/decorators/request-decorator.js.map +1 -1
  26. package/dist/controllers/decorators/route-decorator.d.ts +16 -1
  27. package/dist/controllers/decorators/route-decorator.d.ts.map +1 -1
  28. package/dist/controllers/decorators/route-decorator.js +31 -16
  29. package/dist/controllers/decorators/route-decorator.js.map +1 -1
  30. package/dist/dependency-injection/container.d.ts +4 -3
  31. package/dist/dependency-injection/container.d.ts.map +1 -1
  32. package/dist/dependency-injection/container.js +14 -3
  33. package/dist/dependency-injection/container.js.map +1 -1
  34. package/dist/dependency-injection/injectable-decorator.d.ts +5 -0
  35. package/dist/dependency-injection/injectable-decorator.d.ts.map +1 -1
  36. package/dist/dependency-injection/injectable-decorator.js +9 -0
  37. package/dist/dependency-injection/injectable-decorator.js.map +1 -1
  38. package/dist/exceptions/api-exception.d.ts +4 -7
  39. package/dist/exceptions/api-exception.d.ts.map +1 -1
  40. package/dist/exceptions/api-exception.js +8 -4
  41. package/dist/exceptions/api-exception.js.map +1 -1
  42. package/dist/exceptions/base-exception-filter.d.ts.map +1 -1
  43. package/dist/exceptions/base-exception-filter.js +10 -3
  44. package/dist/exceptions/base-exception-filter.js.map +1 -1
  45. package/dist/exceptions/decorators/use-filters-decorator.d.ts +12 -1
  46. package/dist/exceptions/decorators/use-filters-decorator.d.ts.map +1 -1
  47. package/dist/exceptions/decorators/use-filters-decorator.js +34 -3
  48. package/dist/exceptions/decorators/use-filters-decorator.js.map +1 -1
  49. package/dist/guards/can-activate.d.ts +21 -0
  50. package/dist/guards/can-activate.d.ts.map +1 -0
  51. package/dist/guards/can-activate.js +3 -0
  52. package/dist/guards/can-activate.js.map +1 -0
  53. package/dist/guards/decorators/index.d.ts +2 -0
  54. package/dist/guards/decorators/index.d.ts.map +1 -0
  55. package/dist/guards/decorators/index.js +18 -0
  56. package/dist/guards/decorators/index.js.map +1 -0
  57. package/dist/guards/decorators/use-guards-decorator.d.ts +44 -0
  58. package/dist/guards/decorators/use-guards-decorator.d.ts.map +1 -0
  59. package/dist/guards/decorators/use-guards-decorator.js +127 -0
  60. package/dist/guards/decorators/use-guards-decorator.js.map +1 -0
  61. package/dist/guards/index.d.ts +3 -0
  62. package/dist/guards/index.d.ts.map +1 -0
  63. package/dist/guards/index.js +19 -0
  64. package/dist/guards/index.js.map +1 -0
  65. package/dist/index.d.ts +8 -0
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +13 -1
  68. package/dist/index.js.map +1 -1
  69. package/dist/interceptor/decorators/use-interceptor-decorator.d.ts +10 -3
  70. package/dist/interceptor/decorators/use-interceptor-decorator.d.ts.map +1 -1
  71. package/dist/interceptor/decorators/use-interceptor-decorator.js +52 -22
  72. package/dist/interceptor/decorators/use-interceptor-decorator.js.map +1 -1
  73. package/dist/logger/console-logger.d.ts.map +1 -1
  74. package/dist/logger/console-logger.js +6 -0
  75. package/dist/logger/console-logger.js.map +1 -1
  76. package/dist/middleware/index.d.ts +3 -0
  77. package/dist/middleware/index.d.ts.map +1 -0
  78. package/dist/middleware/index.js +19 -0
  79. package/dist/middleware/index.js.map +1 -0
  80. package/dist/middleware/middleware-handler.d.ts +6 -0
  81. package/dist/middleware/middleware-handler.d.ts.map +1 -0
  82. package/dist/middleware/middleware-handler.js +19 -0
  83. package/dist/middleware/middleware-handler.js.map +1 -0
  84. package/dist/middleware/middleware.d.ts +6 -0
  85. package/dist/middleware/middleware.d.ts.map +1 -0
  86. package/dist/middleware/middleware.js +7 -0
  87. package/dist/middleware/middleware.js.map +1 -0
  88. package/dist/modules/module-decorator.d.ts +2 -2
  89. package/dist/modules/module-decorator.d.ts.map +1 -1
  90. package/dist/modules/module-decorator.js +34 -14
  91. package/dist/modules/module-decorator.js.map +1 -1
  92. package/dist/pipes/decorators/index.d.ts +2 -0
  93. package/dist/pipes/decorators/index.d.ts.map +1 -0
  94. package/dist/pipes/decorators/index.js +6 -0
  95. package/dist/pipes/decorators/index.js.map +1 -0
  96. package/dist/pipes/decorators/use-pipes.d.ts +19 -0
  97. package/dist/pipes/decorators/use-pipes.d.ts.map +1 -0
  98. package/dist/pipes/decorators/use-pipes.js +118 -0
  99. package/dist/pipes/decorators/use-pipes.js.map +1 -0
  100. package/dist/pipes/index.d.ts +3 -0
  101. package/dist/pipes/index.d.ts.map +1 -0
  102. package/dist/pipes/index.js +18 -0
  103. package/dist/pipes/index.js.map +1 -0
  104. package/dist/pipes/pipe-transform.d.ts +46 -0
  105. package/dist/pipes/pipe-transform.d.ts.map +1 -0
  106. package/dist/pipes/pipe-transform.js +3 -0
  107. package/dist/pipes/pipe-transform.js.map +1 -0
  108. package/dist/server/server-factory.d.ts +48 -1
  109. package/dist/server/server-factory.d.ts.map +1 -1
  110. package/dist/server/server-factory.js +169 -34
  111. package/dist/server/server-factory.js.map +1 -1
  112. package/dist/services/guards.d.ts +2 -0
  113. package/dist/services/guards.d.ts.map +1 -0
  114. package/dist/services/guards.js +5 -0
  115. package/dist/services/guards.js.map +1 -0
  116. package/dist/services/middleware.d.ts +2 -0
  117. package/dist/services/middleware.d.ts.map +1 -0
  118. package/dist/services/middleware.js +5 -0
  119. package/dist/services/middleware.js.map +1 -0
  120. package/dist/services/pipes.d.ts +2 -0
  121. package/dist/services/pipes.d.ts.map +1 -0
  122. package/dist/services/pipes.js +5 -0
  123. package/dist/services/pipes.js.map +1 -0
  124. package/dist/utils/routes/route-specificity.d.ts +40 -0
  125. package/dist/utils/routes/route-specificity.d.ts.map +1 -0
  126. package/dist/utils/routes/route-specificity.js +89 -0
  127. package/dist/utils/routes/route-specificity.js.map +1 -0
  128. package/dist/utils/url/url-match.d.ts.map +1 -1
  129. package/dist/utils/url/url-match.js +16 -2
  130. package/dist/utils/url/url-match.js.map +1 -1
  131. package/dist/zod/create-zod-dto.d.ts +16 -0
  132. package/dist/zod/create-zod-dto.d.ts.map +1 -0
  133. package/dist/zod/create-zod-dto.js +14 -0
  134. package/dist/zod/create-zod-dto.js.map +1 -0
  135. package/dist/zod/index.d.ts +3 -0
  136. package/dist/zod/index.d.ts.map +1 -0
  137. package/dist/zod/index.js +8 -0
  138. package/dist/zod/index.js.map +1 -0
  139. package/dist/zod/zod-validation-pipe.d.ts +5 -0
  140. package/dist/zod/zod-validation-pipe.d.ts.map +1 -0
  141. package/dist/zod/zod-validation-pipe.js +35 -0
  142. package/dist/zod/zod-validation-pipe.js.map +1 -0
  143. package/package.json +6 -3
package/README.md CHANGED
@@ -4,15 +4,16 @@ A lightweight, NestJS-inspired framework designed specifically for Next.js appli
4
4
 
5
5
  ## ( Features
6
6
 
7
- - =� **NestJS-like API** - Familiar decorators and patterns
8
- - � **Next.js Optimized** - Built for serverless environments
9
- - =� **Dependency Injection** - Powered by Inversify
10
- - =� **Decorator-based Routing** - Clean, declarative route definitions
11
- - =' **Middleware Support** - Interceptors and exception filters
12
- - =� **TypeScript First** - Full type safety out of the box
13
- - <� **Lightweight** - Minimal overhead for fast cold starts
7
+ - =� **NestJS-like API** - Familiar decorators and patterns
8
+ - � **Next.js Optimized** - Built for serverless environments
9
+ - =� **Dependency Injection** - Powered by Inversify
10
+ - =� **Decorator-based Routing** - Clean, declarative route definitions
11
+ - =' **Middleware Support** - Guards, interceptors, pipes, and exception filters
12
+ - **Zod Validation** - Built-in schema validation with Zod
13
+ - =� **TypeScript First** - Full type safety out of the box
14
+ - <� **Lightweight** - Minimal overhead for fast cold starts
14
15
 
15
- ## =� Quick Start
16
+ ## =� Quick Start
16
17
 
17
18
  ### Installation
18
19
 
@@ -119,7 +120,7 @@ export async function PATCH(request: NextRequest, context: any) {
119
120
  }
120
121
  ```
121
122
 
122
- ## =� Core Concepts
123
+ ## =� Core Concepts
123
124
 
124
125
  ### Controllers
125
126
 
@@ -212,24 +213,41 @@ Create custom exception filters:
212
213
  export class ValidationFilter implements ExceptionFilter {
213
214
  async catch(exception: ValidationError, host: ArgumentsHost) {
214
215
  return NextResponse.json(
215
- {
216
+ {
216
217
  message: 'Validation failed',
217
- errors: exception.errors
218
+ errors: exception.errors
218
219
  },
219
220
  { status: 400 }
220
221
  )
221
222
  }
222
223
  }
223
224
 
224
- // Apply globally
225
+ // Apply globally via app
225
226
  app.useGlobalFilters(new ValidationFilter())
226
227
 
228
+ // Or register via module providers (supports multiple filters)
229
+ @Module({
230
+ providers: [
231
+ {
232
+ provide: APP_FILTER,
233
+ useClass: ValidationFilter
234
+ },
235
+ {
236
+ provide: APP_FILTER,
237
+ useClass: DatabaseErrorFilter
238
+ }
239
+ ]
240
+ })
241
+ export class AppModule {}
242
+
227
243
  // Or on specific controllers
228
244
  @Controller('/users')
229
245
  @UseFilters(ValidationFilter)
230
246
  export class UserController extends BaseController {}
231
247
  ```
232
248
 
249
+ **Note**: When registering multiple filters via `APP_FILTER`, they execute in reverse order (last registered runs first), allowing more specific filters to handle exceptions before general ones.
250
+
233
251
  ### Interceptors
234
252
 
235
253
  Add cross-cutting concerns with interceptors:
@@ -240,22 +258,251 @@ export class LoggingInterceptor implements Interceptor {
240
258
  const start = Date.now()
241
259
  const result = await next.handle()
242
260
  const duration = Date.now() - start
243
-
261
+
244
262
  console.log(`${context.getClass().name}.${context.getHandler().name} - ${duration}ms`)
245
263
  return result
246
264
  }
247
265
  }
248
266
 
249
- // Apply globally
267
+ // Apply globally via app
250
268
  app.useGlobalInterceptors(new LoggingInterceptor())
251
269
 
270
+ // Or register via module providers (supports multiple interceptors)
271
+ @Module({
272
+ providers: [
273
+ {
274
+ provide: APP_INTERCEPTOR,
275
+ useClass: LoggingInterceptor
276
+ },
277
+ {
278
+ provide: APP_INTERCEPTOR,
279
+ useClass: TransformInterceptor
280
+ }
281
+ ]
282
+ })
283
+ export class AppModule {}
284
+
252
285
  // Or on specific controllers
253
286
  @Controller('/users')
254
287
  @UseInterceptors(LoggingInterceptor)
255
288
  export class UserController extends BaseController {}
256
289
  ```
257
290
 
258
- ## <� Parameter Decorators
291
+ **Note**: Multiple `APP_INTERCEPTOR` and `APP_PIPE` providers are supported and execute in reverse registration order (last registered runs first).
292
+
293
+ ### Guards
294
+
295
+ Guards determine whether a request should be handled by the route handler. They're commonly used for authentication and authorization:
296
+
297
+ ```typescript
298
+ import { CanActivate, ExecutionContext, UseGuards } from '@lerianstudio/sindarian-server'
299
+ import { injectable } from 'inversify'
300
+
301
+ @injectable()
302
+ export class AuthGuard implements CanActivate {
303
+ async canActivate(context: ExecutionContext): Promise<boolean> {
304
+ const request = context.switchToHttp().getRequest()
305
+ const token = request.headers.get('authorization')
306
+
307
+ if (!token) {
308
+ return false // Will throw ForbiddenApiException
309
+ }
310
+
311
+ // Validate token...
312
+ return true
313
+ }
314
+ }
315
+
316
+ // Apply to controller
317
+ @Controller('/admin')
318
+ @UseGuards(AuthGuard)
319
+ export class AdminController extends BaseController {
320
+ @Get()
321
+ async dashboard() {
322
+ return { message: 'Welcome to admin' }
323
+ }
324
+ }
325
+
326
+ // Or apply to specific methods
327
+ @Controller('/users')
328
+ export class UserController extends BaseController {
329
+ @Get()
330
+ async findAll() {
331
+ return { users: [] } // Public route
332
+ }
333
+
334
+ @Delete(':id')
335
+ @UseGuards(AuthGuard)
336
+ async remove(@Param('id') id: string) {
337
+ return { deleted: id } // Protected route
338
+ }
339
+ }
340
+ ```
341
+
342
+ Register global guards via module providers:
343
+
344
+ ```typescript
345
+ @Module({
346
+ providers: [
347
+ {
348
+ provide: APP_GUARD,
349
+ useClass: AuthGuard
350
+ }
351
+ ]
352
+ })
353
+ export class AppModule {}
354
+
355
+ // Or globally via app
356
+ app.useGlobalGuards(new AuthGuard())
357
+ ```
358
+
359
+ **Note**: Guards execute before interceptors and pipes. If a guard returns `false`, a `ForbiddenApiException` is thrown.
360
+
361
+ ### Pipes
362
+
363
+ Transform and validate input data with pipes:
364
+
365
+ ```typescript
366
+ import { PipeTransform, ArgumentMetadata, UsePipes } from '@lerianstudio/sindarian-server'
367
+
368
+ @injectable()
369
+ export class ParseIntPipe implements PipeTransform {
370
+ transform(value: any, metadata: ArgumentMetadata): number {
371
+ const val = parseInt(value, 10)
372
+ if (isNaN(val)) {
373
+ throw new Error('Validation failed: not a number')
374
+ }
375
+ return val
376
+ }
377
+ }
378
+
379
+ // Apply to controller or method
380
+ @Controller('/items')
381
+ @UsePipes(ParseIntPipe)
382
+ export class ItemController extends BaseController {
383
+ @Get(':id')
384
+ async findOne(@Param('id') id: number) {
385
+ return this.itemService.findById(id)
386
+ }
387
+ }
388
+ ```
389
+
390
+ Register global pipes via module providers:
391
+
392
+ ```typescript
393
+ @Module({
394
+ providers: [
395
+ {
396
+ provide: APP_PIPE,
397
+ useClass: ValidationPipe
398
+ }
399
+ ]
400
+ })
401
+ export class AppModule {}
402
+ ```
403
+
404
+ ### Validation with Zod
405
+
406
+ Built-in Zod integration for schema validation:
407
+
408
+ ```typescript
409
+ import { createZodDto, ZodValidationPipe, UsePipes } from '@lerianstudio/sindarian-server'
410
+ import { z } from 'zod'
411
+
412
+ // Define your schema
413
+ const CreateUserSchema = z.object({
414
+ name: z.string().min(2),
415
+ email: z.string().email(),
416
+ age: z.number().min(18).optional()
417
+ })
418
+
419
+ // Create a DTO class from the schema
420
+ const CreateUserDto = createZodDto(CreateUserSchema)
421
+
422
+ // Use in your controller with the validation pipe
423
+ @Controller('/users')
424
+ @UsePipes(ZodValidationPipe)
425
+ export class UserController extends BaseController {
426
+ @Post()
427
+ async create(@Body() userData: typeof CreateUserDto) {
428
+ // userData is validated and typed
429
+ return this.userService.create(userData)
430
+ }
431
+ }
432
+ ```
433
+
434
+ The `ZodValidationPipe` automatically validates incoming data against Zod schemas and throws a `ValidationApiException` on validation errors.
435
+
436
+ ### Logger Service
437
+
438
+ Use the built-in logger for consistent application logging:
439
+
440
+ ```typescript
441
+ import { ConsoleLogger, LoggerService } from '@lerianstudio/sindarian-server'
442
+
443
+ // Use the default ConsoleLogger
444
+ const logger = new ConsoleLogger({ prefix: 'MyApp' })
445
+ logger.log('Application started')
446
+ logger.error('Something went wrong')
447
+ logger.warn('This is a warning')
448
+ logger.debug('Debug information')
449
+
450
+ // Or inject as a service
451
+ @injectable()
452
+ export class MyService {
453
+ constructor(private logger: ConsoleLogger) {}
454
+
455
+ doSomething() {
456
+ this.logger.log('Doing something...')
457
+ }
458
+ }
459
+ ```
460
+
461
+ Available log levels: `verbose`, `debug`, `log`, `warn`, `error`, `fatal`
462
+
463
+ ### HttpService
464
+
465
+ Abstract base class for building API client services with built-in error handling:
466
+
467
+ ```typescript
468
+ import { HttpService, FetchModuleOptions } from '@lerianstudio/sindarian-server'
469
+ import { injectable } from 'inversify'
470
+
471
+ @injectable()
472
+ export class MyApiService extends HttpService {
473
+ protected async createDefaults(): Promise<FetchModuleOptions> {
474
+ return {
475
+ baseUrl: 'https://api.example.com',
476
+ headers: {
477
+ 'Content-Type': 'application/json',
478
+ 'Authorization': `Bearer ${this.getToken()}`
479
+ }
480
+ }
481
+ }
482
+
483
+ async getUsers() {
484
+ return this.get<User[]>('/users')
485
+ }
486
+
487
+ async createUser(data: CreateUserDto) {
488
+ return this.post<User>('/users', {
489
+ body: JSON.stringify(data)
490
+ })
491
+ }
492
+
493
+ async uploadFile(data: { file: File; name: string }) {
494
+ return this.postFormData<UploadResponse>('/upload', data)
495
+ }
496
+ }
497
+ ```
498
+
499
+ The `HttpService` provides:
500
+ - HTTP methods: `get`, `post`, `put`, `patch`, `delete`, `head`
501
+ - FormData support: `postFormData`, `patchFormData`
502
+ - Automatic error handling with typed exceptions
503
+ - Lifecycle hooks: `onBeforeFetch`, `onAfterFetch`, `catch`
504
+
505
+ ## <� Parameter Decorators
259
506
 
260
507
  Extract data from requests with decorators:
261
508
 
@@ -333,7 +580,7 @@ export class AuthService {
333
580
  }
334
581
  ```
335
582
 
336
- ## =� Documentation
583
+ ## =� Documentation
337
584
 
338
585
  - **[Technical Guide](./TECHNICAL.md)** - Deep dive into the framework's architecture and implementation details
339
586
  - **[API Reference](./docs/api.md)** - Complete API documentation
@@ -343,7 +590,7 @@ export class AuthService {
343
590
 
344
591
  Contributions are welcome! Please read our [Contributing Guide](./CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
345
592
 
346
- ## =� License
593
+ ## =� License
347
594
 
348
595
  This project is licensed under the ISC License - see the [LICENSE](./LICENSE) file for details.
349
596
 
@@ -353,10 +600,10 @@ This project is licensed under the ISC License - see the [LICENSE](./LICENSE) fi
353
600
  - Built on [Inversify](https://inversify.io/) - A powerful IoC container for TypeScript
354
601
  - Designed for [Next.js](https://nextjs.org/) - The React framework for production
355
602
 
356
- ## =� What's Next?
603
+ ## =� What's Next?
357
604
 
358
- - [ ] Validation pipes with Zod integration
359
- - [ ] Built-in authentication guards
605
+ - [x] Validation pipes with Zod integration
606
+ - [x] Guards system for authentication/authorization
360
607
  - [ ] WebSocket support
361
608
  - [ ] GraphQL integration
362
609
  - [ ] CLI tools for scaffolding
@@ -364,4 +611,4 @@ This project is licensed under the ISC License - see the [LICENSE](./LICENSE) fi
364
611
 
365
612
  ---
366
613
 
367
- **Sindarian Server** - Building the future of Next.js APIs, one decorator at a time. =�
614
+ **Sindarian Server** - Building the future of Next.js APIs, one decorator at a time. =�
@@ -1,9 +1,12 @@
1
1
  export declare const INJECTABLE_KEY: unique symbol;
2
+ export declare const CLASS_NAME_KEY: unique symbol;
2
3
  export declare const MODULE_KEY: unique symbol;
3
4
  export declare const CONTROLLER_KEY: unique symbol;
4
5
  export declare const CATCH_KEY: unique symbol;
5
6
  export declare const FILTER_KEY: unique symbol;
6
7
  export declare const INTERCEPTOR_KEY: unique symbol;
8
+ export declare const PIPE_KEY: unique symbol;
9
+ export declare const GUARD_KEY: unique symbol;
7
10
  export declare const ROUTE_KEY: unique symbol;
8
11
  export declare const GET_KEY: unique symbol;
9
12
  export declare const POST_KEY: unique symbol;
@@ -1 +1 @@
1
- {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/constants/keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,eAAuB,CAAA;AAElD,eAAO,MAAM,UAAU,eAAmB,CAAA;AAC1C,eAAO,MAAM,cAAc,eAAuB,CAAA;AAClD,eAAO,MAAM,SAAS,eAAkB,CAAA;AACxC,eAAO,MAAM,UAAU,eAAmB,CAAA;AAC1C,eAAO,MAAM,eAAe,eAAwB,CAAA;AAEpD,eAAO,MAAM,SAAS,eAAkB,CAAA;AACxC,eAAO,MAAM,OAAO,eAAgB,CAAA;AACpC,eAAO,MAAM,QAAQ,eAAiB,CAAA;AACtC,eAAO,MAAM,OAAO,eAAgB,CAAA;AACpC,eAAO,MAAM,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e,CAAA;AAC3C,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AACjD,eAAO,MAAM,oBAAoB,oBAAoB,CAAA"}
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CONTROLLERS_PROPERTY = exports.PROVIDERS_PROPERTY = exports.MODULE_PROPERTY = exports.IMPORTS_PROPERTY = exports.QUERY_KEY = exports.PARAM_KEY = exports.REQUEST_KEY = exports.BODY_KEY = exports.DELETE_KEY = exports.PATCH_KEY = exports.PUT_KEY = exports.POST_KEY = exports.GET_KEY = exports.ROUTE_KEY = exports.INTERCEPTOR_KEY = exports.FILTER_KEY = exports.CATCH_KEY = exports.CONTROLLER_KEY = exports.MODULE_KEY = exports.INJECTABLE_KEY = void 0;
3
+ exports.CONTROLLERS_PROPERTY = exports.PROVIDERS_PROPERTY = exports.MODULE_PROPERTY = exports.IMPORTS_PROPERTY = exports.QUERY_KEY = exports.PARAM_KEY = exports.REQUEST_KEY = exports.BODY_KEY = exports.DELETE_KEY = exports.PATCH_KEY = exports.PUT_KEY = exports.POST_KEY = exports.GET_KEY = exports.ROUTE_KEY = exports.GUARD_KEY = exports.PIPE_KEY = exports.INTERCEPTOR_KEY = exports.FILTER_KEY = exports.CATCH_KEY = exports.CONTROLLER_KEY = exports.MODULE_KEY = exports.CLASS_NAME_KEY = exports.INJECTABLE_KEY = void 0;
4
4
  exports.INJECTABLE_KEY = Symbol('injectable');
5
+ exports.CLASS_NAME_KEY = Symbol('class_name');
5
6
  exports.MODULE_KEY = Symbol('module');
6
7
  exports.CONTROLLER_KEY = Symbol('controller');
7
8
  exports.CATCH_KEY = Symbol('catch');
8
9
  exports.FILTER_KEY = Symbol('filter');
9
10
  exports.INTERCEPTOR_KEY = Symbol('interceptor');
11
+ exports.PIPE_KEY = Symbol('pipe');
12
+ exports.GUARD_KEY = Symbol('guard');
10
13
  exports.ROUTE_KEY = Symbol('route');
11
14
  exports.GET_KEY = Symbol('get');
12
15
  exports.POST_KEY = Symbol('post');
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/constants/keys.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;AAErC,QAAA,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC7B,QAAA,cAAc,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;AACrC,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAC3B,QAAA,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC7B,QAAA,eAAe,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;AAEvC,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAC3B,QAAA,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;AACvB,QAAA,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;AACzB,QAAA,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;AACvB,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAC3B,QAAA,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;AAE7B,QAAA,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;AACzB,QAAA,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;AAC/B,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAC3B,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAE3B,QAAA,gBAAgB,GAAG,aAAa,CAAA;AAChC,QAAA,eAAe,GAAG,YAAY,CAAA;AAC9B,QAAA,kBAAkB,GAAG,eAAe,CAAA;AACpC,QAAA,oBAAoB,GAAG,iBAAiB,CAAA"}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/constants/keys.ts"],"names":[],"mappings":";;;AAAa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Metadata = {
2
- propertyIndex: number;
3
- schema?: () => any;
4
- };
5
- /**
6
- * Handler to validate the body of the request.
7
- *
8
- * @param target - The target object.
9
- * @param propertyKey - The property key.
10
- * @param args - The arguments.
11
- * @returns The parameter and parameter index.
12
- */
13
- export declare function bodyDecoratorHandler(target: object, propertyKey: string | symbol, args: any[]): Promise<{
14
- parameter: any;
15
2
  parameterIndex: number;
16
- } | null>;
3
+ };
4
+ export declare class BodyHandler {
5
+ private static bodyCache;
6
+ static getMetadata(target: object, propertyKey: string | symbol): BodyMetadata | undefined;
7
+ static handle(target: object, propertyKey: string | symbol, args: any[]): Promise<{
8
+ type: string;
9
+ parameter: any;
10
+ parameterIndex: number;
11
+ paramType: any;
12
+ } | null>;
13
+ }
17
14
  /**
18
15
  * Decorator to validate the body of the request.
19
16
  *
20
- * @param schema - The Zod schema to validate the body against.
21
17
  * @returns A decorator function that can be used to decorate a controller method.
22
18
  */
23
- export declare function Body(schema?: any): (target: object, propertyKey: string | symbol, propertyIndex: number) => void;
19
+ export declare function Body(): (target: object, propertyKey: string | symbol, propertyIndex: number) => void;
24
20
  //# sourceMappingURL=body-decorator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"body-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/body-decorator.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,CAAA;CACnB,CAAA;AAKD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,IAAI,EAAE,GAAG,EAAE;;;UA6DZ;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,IAE7B,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,eAAe,MAAM,UAQxB"}
1
+ {"version":3,"file":"body-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/body-decorator.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG;IACzB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,qBAAa,WAAW;IAEtB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkC;IAE1D,MAAM,CAAC,WAAW,CAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,YAAY,GAAG,SAAS;WAmBd,MAAM,CACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,IAAI,EAAE,GAAG,EAAE;;;;;;CAqDd;AAED;;;;GAIG;AACH,wBAAgB,IAAI,KAEhB,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,eAAe,MAAM,UAWxB"}
@@ -1,83 +1,77 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bodyDecoratorHandler = bodyDecoratorHandler;
3
+ exports.BodyHandler = void 0;
4
4
  exports.Body = Body;
5
5
  const keys_1 = require("../../constants/keys");
6
6
  const get_next_arguments_1 = require("../../utils/nextjs/get-next-arguments");
7
7
  const api_exception_1 = require("../../exceptions/api-exception");
8
8
  const get_form_data_1 = require("../../utils/form-data/get-form-data");
9
- // Cache to store parsed body to avoid reading it multiple times
10
- const bodyCache = new WeakMap();
11
- /**
12
- * Handler to validate the body of the request.
13
- *
14
- * @param target - The target object.
15
- * @param propertyKey - The property key.
16
- * @param args - The arguments.
17
- * @returns The parameter and parameter index.
18
- */
19
- async function bodyDecoratorHandler(target, propertyKey, args) {
20
- const metadata = Reflect.getOwnMetadata(keys_1.BODY_KEY, target, propertyKey);
21
- // If the metadata is not found, return null.
22
- if (metadata) {
23
- const request = (0, get_next_arguments_1.getNextRequestArgument)(args);
24
- // Check if body is already cached
25
- let body = bodyCache.get(request);
26
- if (!body) {
27
- const contentType = request.headers.get('Content-Type');
28
- try {
29
- if (contentType?.includes('multipart/form-data')) {
30
- body = (0, get_form_data_1.getFormData)(await request.formData());
31
- }
32
- else if (contentType?.includes('application/json')) {
33
- body = await request.json();
9
+ class BodyHandler {
10
+ static getMetadata(target, propertyKey) {
11
+ let metadata = Reflect.getOwnMetadata(keys_1.BODY_KEY, target, propertyKey);
12
+ // If not found on instance, try constructor prototype
13
+ if (!metadata && target.constructor) {
14
+ metadata = Reflect.getOwnMetadata(keys_1.BODY_KEY, target.constructor.prototype, propertyKey);
15
+ }
16
+ return metadata;
17
+ }
18
+ static async handle(target, propertyKey, args) {
19
+ const metadata = this.getMetadata(target, propertyKey);
20
+ // If the metadata is not found, return null.
21
+ if (metadata) {
22
+ // Get the route metadata to access paramTypes (check both target and prototype)
23
+ let routeMetadata = Reflect.getOwnMetadata(keys_1.ROUTE_KEY, target, propertyKey);
24
+ if (!routeMetadata && target.constructor) {
25
+ routeMetadata = Reflect.getOwnMetadata(keys_1.ROUTE_KEY, target.constructor.prototype, propertyKey);
26
+ }
27
+ const paramTypes = routeMetadata?.paramTypes || [];
28
+ const request = (0, get_next_arguments_1.getNextRequestArgument)(args);
29
+ // Check if body is already cached
30
+ let body = this.bodyCache.get(request);
31
+ if (!body) {
32
+ const contentType = request.headers.get('Content-Type');
33
+ try {
34
+ if (contentType?.includes('multipart/form-data')) {
35
+ body = (0, get_form_data_1.getFormData)(await request.formData());
36
+ }
37
+ else if (contentType?.includes('application/json')) {
38
+ body = await request.json();
39
+ }
40
+ else {
41
+ body = await request.text();
42
+ }
43
+ // Cache the parsed body
44
+ this.bodyCache.set(request, body);
45
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
46
  }
35
- else {
36
- body = await request.text();
47
+ catch (error) {
48
+ // Handle missing or invalid body
49
+ throw new api_exception_1.ValidationApiException('Missing or invalid request body');
37
50
  }
38
- // Cache the parsed body
39
- bodyCache.set(request, body);
40
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
- }
42
- catch (error) {
43
- // Handle missing or invalid body
44
- throw new api_exception_1.ValidationApiException('Missing or invalid request body');
45
51
  }
46
- }
47
- // If the schema is not provided, return the body.
48
- if (!metadata.schema) {
49
52
  return {
53
+ type: 'body',
50
54
  parameter: body,
51
- parameterIndex: metadata.propertyIndex
55
+ parameterIndex: metadata.parameterIndex,
56
+ paramType: paramTypes[metadata.parameterIndex]
52
57
  };
53
58
  }
54
- // Parse the body using the schema.
55
- const resolvedSchema = metadata.schema?.();
56
- const parsedBody = resolvedSchema?.safeParse(body);
57
- // If the body is not valid, throw a validation error.
58
- if (parsedBody && !parsedBody.success) {
59
- throw new api_exception_1.ValidationApiException(`Invalid body: ${JSON.stringify(parsedBody.error.flatten().fieldErrors)}`);
60
- }
61
- return {
62
- parameter: body,
63
- parameterIndex: metadata.propertyIndex
64
- };
59
+ return null;
65
60
  }
66
- return null;
67
61
  }
62
+ exports.BodyHandler = BodyHandler;
63
+ // Cache to store parsed body to avoid reading it multiple times
64
+ BodyHandler.bodyCache = new WeakMap();
68
65
  /**
69
66
  * Decorator to validate the body of the request.
70
67
  *
71
- * @param schema - The Zod schema to validate the body against.
72
68
  * @returns A decorator function that can be used to decorate a controller method.
73
69
  */
74
- function Body(schema) {
70
+ function Body() {
75
71
  return function (target, propertyKey, propertyIndex) {
76
- const metadata = {
77
- propertyIndex,
78
- schema: schema ? () => schema : undefined
79
- };
80
- Reflect.defineMetadata(keys_1.BODY_KEY, metadata, target, propertyKey);
72
+ Reflect.defineMetadata(keys_1.BODY_KEY, {
73
+ parameterIndex: propertyIndex
74
+ }, target, propertyKey);
81
75
  };
82
76
  }
83
77
  //# sourceMappingURL=body-decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"body-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/body-decorator.ts"],"names":[],"mappings":";;AAsBA,oDAgEC;AAQD,oBAYC;AA1GD,2CAA2C;AAC3C,0EAA0E;AAC1E,8DAAmE;AAEnE,mEAA6D;AAO7D,gEAA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ACL,SAAS,EAAE,IAAI;gBACf,cAAc,EAAE,QAAQ,CAAC,aAAa;aACvC,CAAA;QACH,CAAC;QAED,mCAAmC;QACnC,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAA;QAC1C,MAAM,UAAU,GAAG,cAAc,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QAElD,sDAAsD;QACtD,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACtC,MAAM,IAAI,sCAAsB,CAC9B,iBAAiB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,CAC1E,CAAA;QACH,CAAC;QAED,OAAO;YACL,SAAS,EAAE,IAAI;YACf,cAAc,EAAE,QAAQ,CAAC,aAAa;SACvC,CAAA;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;GAKG;AACH,SAAgB,IAAI,CAAC,MAAY;IAC/B,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,aAAqB;QAErB,MAAM,QAAQ,GAAiB;YAC7B,aAAa;YACb,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SAC1C,CAAA;QACD,OAAO,CAAC,cAAc,CAAC,eAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;IACjE,CAAC,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"body-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/body-decorator.ts"],"names":[],"mappings":";;;AAmGA,oBAeC;AAlHD,2CAAsD;AACtD,0EAA0E;AAC1E,8DAAmE;AAEnE,mEAA6D;AAM7D,MAAa,WAAW;IAItB,MAAM,CAAC,WAAW,CAChB,MAAc,EACd,WAA4B;QAE5B,IAAI,QAAQ,GAAiB,OAAO,CAAC,cAAc,CACjD,eAAQ,EACR,MAAM,EACN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AAA;oBAC9C,CAAC;yBAAM,IAAI,WAAW,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;wBACrD,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;oBAC7B,CAAC;yBAAM,CAAC;wBACN,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;oBAC7B,CAAC;oBAED,wBAAwB;oBACxB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;oBACjC,6DAA6D;gBAC/D,CAAC;gBAAC,OAAO,KAAU,EAAE,CAAC;oBACpB,iCAAiC;oBACjC,MAAM,IAAI,sCAAsB,CAAC,iCAAiC,CAAC,CAAA;gBACrE,CAAC;YACH,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,SAAS,EAAE,IAAI;gBACf,cAAc,EAAE,QAAQ,CAAC,cAAc;gBACvC,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC;aAC/C,CAAA;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;;AAjFH,kCAkFC;AAjFC,gEAAgE;AACjD,qBAAS,GAAG,IAAI,OAAO,EAAoB,CAAA;AAkF5D;;;;GAIG;AACH,SAAgB,IAAI;IAClB,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,aAAqB;QAErB,OAAO,CAAC,cAAc,CACpB,eAAQ,EACR;YACE,cAAc,EAAE,aAAa;SAC9B,EACD,MAAM,EACN,WAAW,CACZ,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -1,10 +1,11 @@
1
- import { HttpMethods } from '../../constants/http-methods';
1
+ import { RouteMetadata } from './route-decorator';
2
2
  export type ControllerMetadata = {
3
- methodName: string;
4
- method: HttpMethods;
5
3
  path: string;
6
4
  };
7
- export declare function controllerHandler(target: Function): ControllerMetadata[];
5
+ export declare class ControllerHandler {
6
+ static getMetadata(target: object): ControllerMetadata | undefined;
7
+ static getRoutes(target: Function): RouteMetadata[];
8
+ }
8
9
  /**
9
10
  * A class decorator that wraps all methods in the class with error handling.
10
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"controller-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/controller-decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAOtD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,WAAW,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,wBA+BjD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAIvD"}
1
+ {"version":3,"file":"controller-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/controller-decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAK/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIlE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG,aAAa,EAAE;CAiCpD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAIvD"}