@velajs/vela 0.4.3 → 0.5.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 (68) hide show
  1. package/dist/cache/cache.module.d.ts +4 -1
  2. package/dist/cache/cache.module.js +51 -9
  3. package/dist/config/config.module.d.ts +4 -1
  4. package/dist/config/config.module.js +40 -3
  5. package/dist/config/config.types.d.ts +1 -0
  6. package/dist/constants.d.ts +8 -2
  7. package/dist/constants.js +6 -0
  8. package/dist/container/container.d.ts +2 -0
  9. package/dist/container/container.js +51 -16
  10. package/dist/container/decorators.d.ts +3 -1
  11. package/dist/container/decorators.js +27 -6
  12. package/dist/container/index.d.ts +4 -2
  13. package/dist/container/index.js +4 -2
  14. package/dist/container/mixin.d.ts +24 -0
  15. package/dist/container/mixin.js +26 -0
  16. package/dist/container/module-ref.d.ts +21 -0
  17. package/dist/container/module-ref.js +48 -0
  18. package/dist/container/types.d.ts +9 -3
  19. package/dist/container/types.js +9 -0
  20. package/dist/cors/cors.module.js +2 -2
  21. package/dist/errors/http-exception.d.ts +20 -20
  22. package/dist/errors/http-exception.js +47 -41
  23. package/dist/factory.js +11 -2
  24. package/dist/fetch/fetch.module.d.ts +6 -0
  25. package/dist/fetch/fetch.module.js +77 -0
  26. package/dist/fetch/fetch.service.d.ts +24 -0
  27. package/dist/fetch/fetch.service.js +145 -0
  28. package/dist/fetch/fetch.types.d.ts +24 -0
  29. package/dist/fetch/fetch.types.js +1 -0
  30. package/dist/fetch/index.d.ts +3 -0
  31. package/dist/fetch/index.js +2 -0
  32. package/dist/health/health.service.js +2 -2
  33. package/dist/http/decorators.d.ts +65 -0
  34. package/dist/http/decorators.js +91 -2
  35. package/dist/http/index.d.ts +3 -1
  36. package/dist/http/index.js +2 -1
  37. package/dist/http/middleware-consumer.d.ts +36 -0
  38. package/dist/http/middleware-consumer.js +71 -0
  39. package/dist/http/route.manager.d.ts +4 -0
  40. package/dist/http/route.manager.js +91 -6
  41. package/dist/http/types.d.ts +1 -0
  42. package/dist/index.d.ts +11 -6
  43. package/dist/index.js +7 -4
  44. package/dist/metadata.d.ts +1 -1
  45. package/dist/module/decorators.d.ts +1 -0
  46. package/dist/module/decorators.js +24 -8
  47. package/dist/module/index.d.ts +2 -2
  48. package/dist/module/index.js +1 -1
  49. package/dist/module/module-loader.d.ts +5 -1
  50. package/dist/module/module-loader.js +54 -10
  51. package/dist/module/types.d.ts +13 -3
  52. package/dist/pipeline/index.d.ts +3 -2
  53. package/dist/pipeline/index.js +1 -1
  54. package/dist/pipeline/pipes.d.ts +22 -0
  55. package/dist/pipeline/pipes.js +50 -0
  56. package/dist/pipeline/tokens.d.ts +1 -1
  57. package/dist/pipeline/tokens.js +1 -1
  58. package/dist/pipeline/types.d.ts +16 -0
  59. package/dist/registry/metadata.registry.d.ts +7 -6
  60. package/dist/registry/metadata.registry.js +13 -0
  61. package/dist/registry/types.d.ts +1 -0
  62. package/dist/schedule/schedule.module.d.ts +4 -1
  63. package/dist/schedule/schedule.module.js +39 -7
  64. package/dist/testing/testing.builder.js +5 -5
  65. package/dist/throttler/throttler.module.d.ts +2 -1
  66. package/dist/throttler/throttler.module.js +47 -9
  67. package/dist/validation/validation.pipe.js +1 -1
  68. package/package.json +1 -1
@@ -5,14 +5,18 @@ import { APP_GUARD } from "../pipeline/tokens.js";
5
5
  import { ThrottlerGuard } from "./throttler.guard.js";
6
6
  import { ThrottlerStorage } from "./throttler.storage.js";
7
7
  import { THROTTLER_OPTIONS, THROTTLER_STORAGE } from "./throttler.tokens.js";
8
+ function makeThrottlerModuleClass() {
9
+ const moduleClass = class ThrottlerDynamicModule {
10
+ };
11
+ Object.defineProperty(moduleClass, 'name', {
12
+ value: 'ThrottlerModule'
13
+ });
14
+ defineMetadata(METADATA_KEYS.MODULE, true, moduleClass);
15
+ return moduleClass;
16
+ }
8
17
  export class ThrottlerModule {
9
18
  static forRoot(options) {
10
- const moduleClass = class ThrottlerDynamicModule {
11
- };
12
- Object.defineProperty(moduleClass, 'name', {
13
- value: 'ThrottlerModule'
14
- });
15
- defineMetadata(METADATA_KEYS.MODULE, true, moduleClass);
19
+ const moduleClass = makeThrottlerModuleClass();
16
20
  MetadataRegistry.setModuleOptions(moduleClass, {
17
21
  exports: [
18
22
  THROTTLER_OPTIONS,
@@ -22,16 +26,50 @@ export class ThrottlerModule {
22
26
  });
23
27
  const providers = [
24
28
  {
25
- token: THROTTLER_OPTIONS,
29
+ provide: THROTTLER_OPTIONS,
26
30
  useValue: options
27
31
  },
28
32
  {
29
- token: THROTTLER_STORAGE,
33
+ provide: THROTTLER_STORAGE,
30
34
  useValue: options.storage ?? new ThrottlerStorage()
31
35
  },
32
36
  ThrottlerGuard,
33
37
  {
34
- token: APP_GUARD,
38
+ provide: APP_GUARD,
39
+ useExisting: ThrottlerGuard
40
+ }
41
+ ];
42
+ return {
43
+ module: moduleClass,
44
+ providers
45
+ };
46
+ }
47
+ static forRootAsync(options) {
48
+ const moduleClass = makeThrottlerModuleClass();
49
+ MetadataRegistry.setModuleOptions(moduleClass, {
50
+ imports: options.imports ?? [],
51
+ exports: [
52
+ THROTTLER_OPTIONS,
53
+ THROTTLER_STORAGE,
54
+ ThrottlerGuard
55
+ ]
56
+ });
57
+ const providers = [
58
+ {
59
+ provide: THROTTLER_OPTIONS,
60
+ useFactory: options.useFactory,
61
+ inject: options.inject ?? []
62
+ },
63
+ {
64
+ provide: THROTTLER_STORAGE,
65
+ useFactory: (opts)=>opts.storage ?? new ThrottlerStorage(),
66
+ inject: [
67
+ THROTTLER_OPTIONS
68
+ ]
69
+ },
70
+ ThrottlerGuard,
71
+ {
72
+ provide: APP_GUARD,
35
73
  useExisting: ThrottlerGuard
36
74
  }
37
75
  ];
@@ -7,7 +7,7 @@ export class ValidationPipe {
7
7
  return metatype.schema.parse(value);
8
8
  } catch (error) {
9
9
  if (error && typeof error === 'object' && 'issues' in error && Array.isArray(error.issues)) {
10
- throw new BadRequestException('Validation failed', {
10
+ throw new BadRequestException({
11
11
  statusCode: 400,
12
12
  message: 'Validation failed',
13
13
  errors: error.issues
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velajs/vela",
3
- "version": "0.4.3",
3
+ "version": "0.5.1",
4
4
  "description": "NestJS-compatible framework for edge runtimes, powered by Hono",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",