@riktajs/core 0.9.0 → 0.10.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 (93) hide show
  1. package/README.md +132 -132
  2. package/dist/core/application.d.ts +1 -1
  3. package/dist/core/application.js +36 -43
  4. package/dist/core/config/abstract-config-provider.js +8 -13
  5. package/dist/core/config/env-loader.js +12 -17
  6. package/dist/core/config/index.d.ts +2 -2
  7. package/dist/core/config/index.js +2 -18
  8. package/dist/core/constants.js +18 -21
  9. package/dist/core/container/abstract-class.utils.d.ts +1 -1
  10. package/dist/core/container/abstract-class.utils.js +14 -24
  11. package/dist/core/container/container.d.ts +2 -2
  12. package/dist/core/container/container.js +16 -20
  13. package/dist/core/container/implements.decorator.d.ts +1 -1
  14. package/dist/core/container/implements.decorator.js +17 -23
  15. package/dist/core/container/index.d.ts +5 -5
  16. package/dist/core/container/index.js +5 -21
  17. package/dist/core/container/injection-token.js +1 -5
  18. package/dist/core/container/request-scope.d.ts +1 -1
  19. package/dist/core/container/request-scope.js +4 -8
  20. package/dist/core/decorators/apply-decorators.js +3 -7
  21. package/dist/core/decorators/autowired.decorator.d.ts +1 -1
  22. package/dist/core/decorators/autowired.decorator.js +12 -16
  23. package/dist/core/decorators/config-property.decorator.js +9 -15
  24. package/dist/core/decorators/controller.decorator.js +9 -12
  25. package/dist/core/decorators/create-param-decorator.d.ts +1 -1
  26. package/dist/core/decorators/create-param-decorator.js +7 -12
  27. package/dist/core/decorators/index.d.ts +9 -9
  28. package/dist/core/decorators/index.js +9 -25
  29. package/dist/core/decorators/injectable.decorator.d.ts +1 -1
  30. package/dist/core/decorators/injectable.decorator.js +8 -11
  31. package/dist/core/decorators/param.decorator.d.ts +1 -1
  32. package/dist/core/decorators/param.decorator.js +14 -17
  33. package/dist/core/decorators/provider.decorator.d.ts +2 -2
  34. package/dist/core/decorators/provider.decorator.js +12 -17
  35. package/dist/core/decorators/route.decorator.js +13 -17
  36. package/dist/core/discovery.d.ts +1 -1
  37. package/dist/core/discovery.js +25 -57
  38. package/dist/core/exceptions/catch.decorator.d.ts +1 -1
  39. package/dist/core/exceptions/catch.decorator.js +6 -11
  40. package/dist/core/exceptions/config.exceptions.js +3 -9
  41. package/dist/core/exceptions/discovery.exception.js +1 -5
  42. package/dist/core/exceptions/exception-filter.js +5 -10
  43. package/dist/core/exceptions/exceptions.d.ts +1 -1
  44. package/dist/core/exceptions/exceptions.js +19 -40
  45. package/dist/core/exceptions/http-exception.js +1 -5
  46. package/dist/core/exceptions/index.d.ts +7 -7
  47. package/dist/core/exceptions/index.js +7 -39
  48. package/dist/core/exceptions/validation.exception.d.ts +1 -1
  49. package/dist/core/exceptions/validation.exception.js +2 -6
  50. package/dist/core/guards/can-activate.interface.d.ts +1 -1
  51. package/dist/core/guards/can-activate.interface.js +1 -2
  52. package/dist/core/guards/execution-context.d.ts +1 -1
  53. package/dist/core/guards/execution-context.js +1 -5
  54. package/dist/core/guards/index.d.ts +3 -3
  55. package/dist/core/guards/index.js +2 -8
  56. package/dist/core/guards/use-guards.decorator.d.ts +2 -2
  57. package/dist/core/guards/use-guards.decorator.js +10 -14
  58. package/dist/core/index.d.ts +16 -16
  59. package/dist/core/index.js +17 -35
  60. package/dist/core/interceptors/index.d.ts +2 -2
  61. package/dist/core/interceptors/index.js +1 -6
  62. package/dist/core/interceptors/interceptor.interface.d.ts +1 -1
  63. package/dist/core/interceptors/interceptor.interface.js +1 -2
  64. package/dist/core/interceptors/use-interceptors.decorator.d.ts +2 -2
  65. package/dist/core/interceptors/use-interceptors.decorator.js +10 -14
  66. package/dist/core/lifecycle/event-bus.d.ts +1 -1
  67. package/dist/core/lifecycle/event-bus.js +4 -7
  68. package/dist/core/lifecycle/index.d.ts +3 -3
  69. package/dist/core/lifecycle/index.js +3 -19
  70. package/dist/core/lifecycle/interfaces.js +1 -2
  71. package/dist/core/lifecycle/on.decorator.d.ts +1 -1
  72. package/dist/core/lifecycle/on.decorator.js +5 -9
  73. package/dist/core/metadata.d.ts +2 -2
  74. package/dist/core/metadata.js +26 -43
  75. package/dist/core/middleware/index.d.ts +3 -3
  76. package/dist/core/middleware/index.js +2 -9
  77. package/dist/core/middleware/middleware.decorator.js +2 -5
  78. package/dist/core/middleware/rikta-middleware.interface.js +1 -2
  79. package/dist/core/middleware/use-middleware.decorator.d.ts +2 -2
  80. package/dist/core/middleware/use-middleware.decorator.js +10 -14
  81. package/dist/core/profiler/index.d.ts +2 -2
  82. package/dist/core/profiler/index.js +1 -8
  83. package/dist/core/profiler/performance-profiler.d.ts +1 -1
  84. package/dist/core/profiler/performance-profiler.js +6 -12
  85. package/dist/core/registry.d.ts +1 -1
  86. package/dist/core/registry.js +4 -7
  87. package/dist/core/router/router.d.ts +2 -2
  88. package/dist/core/router/router.js +31 -35
  89. package/dist/core/types.d.ts +3 -3
  90. package/dist/core/types.js +1 -2
  91. package/dist/index.d.ts +2 -2
  92. package/dist/index.js +2 -20
  93. package/package.json +8 -1
package/README.md CHANGED
@@ -1,132 +1,132 @@
1
- # @riktajs/core
2
-
3
- The core package of the Rikta framework.
4
-
5
- See the [main repository README](../../README.md) for full documentation.
6
-
7
- ## Installation
8
-
9
- ```bash
10
- npm install @riktajs/core
11
- ```
12
-
13
- ## Quick Start
14
-
15
- ```typescript
16
- import { Rikta, Controller, Injectable, Get, Autowired } from '@riktajs/core';
17
-
18
- @Injectable()
19
- class HelloService {
20
- getMessage() {
21
- return { message: 'Hello from Rikta!' };
22
- }
23
- }
24
-
25
- @Controller('/api')
26
- class HelloController {
27
- @Autowired()
28
- private helloService!: HelloService;
29
-
30
- @Get('/hello')
31
- getHello() {
32
- return this.helloService.getMessage();
33
- }
34
- }
35
-
36
- const app = await Rikta.create({
37
- port: 3000,
38
- autowired: ['./src']
39
- });
40
- await app.listen();
41
- ```
42
-
43
- ## Features
44
-
45
- - 🚀 Zero-Config Autowiring
46
- - ⚡ Fastify Powered
47
- - 🛡️ Type-Safe by Default
48
- - 🔄 Hybrid Lifecycle
49
- - 📦 Built-in Dependency Injection
50
- - ✅ Zod Validation Integration
51
-
52
- ## Provider Scopes
53
-
54
- Rikta supports three provider scopes:
55
-
56
- ```typescript
57
- // Singleton (default) - shared instance
58
- @Injectable()
59
- class ConfigService {}
60
-
61
- // Transient - new instance each time
62
- @Injectable({ scope: 'transient' })
63
- class RequestLogger {}
64
-
65
- // Request - one instance per HTTP request
66
- @Injectable({ scope: 'request' })
67
- class RequestContext {}
68
- ```
69
-
70
- ## Strict Discovery Mode
71
-
72
- Enable strict discovery to catch import errors early:
73
-
74
- ```typescript
75
- const app = await Rikta.create({
76
- strictDiscovery: process.env.NODE_ENV !== 'production',
77
- onDiscoveryError: (file, error) => {
78
- console.warn(`Failed to import: ${file}`);
79
- },
80
- });
81
- ```
82
-
83
- ## EventBus
84
-
85
- The EventBus provides pub/sub for lifecycle events:
86
-
87
- ```typescript
88
- import { Injectable, Autowired, EventBus } from '@riktajs/core';
89
-
90
- @Injectable()
91
- class MonitorService {
92
- @Autowired()
93
- private events!: EventBus;
94
-
95
- onProviderInit() {
96
- this.events.on('app:listen', ({ address }) => {
97
- console.log(`Server at ${address}`);
98
- });
99
- }
100
- }
101
- ```
102
-
103
- ## Interceptors
104
-
105
- Interceptors allow you to bind extra logic before/after method execution:
106
-
107
- ```typescript
108
- import { Injectable, Interceptor, ExecutionContext, CallHandler, UseInterceptors } from '@riktajs/core';
109
-
110
- @Injectable()
111
- class LoggingInterceptor implements Interceptor {
112
- async intercept(context: ExecutionContext, next: CallHandler): Promise<unknown> {
113
- const start = Date.now();
114
- const result = await next.handle();
115
- console.log(`Request took ${Date.now() - start}ms`);
116
- return result;
117
- }
118
- }
119
-
120
- @Controller('/api')
121
- @UseInterceptors(LoggingInterceptor)
122
- class ApiController {
123
- @Get('/data')
124
- getData() {
125
- return { data: 'example' };
126
- }
127
- }
128
- ```
129
-
130
- ## License
131
-
132
- MIT
1
+ # @riktajs/core
2
+
3
+ The core package of the Rikta framework.
4
+
5
+ See the [main repository README](../../README.md) for full documentation.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @riktajs/core
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { Rikta, Controller, Injectable, Get, Autowired } from '@riktajs/core';
17
+
18
+ @Injectable()
19
+ class HelloService {
20
+ getMessage() {
21
+ return { message: 'Hello from Rikta!' };
22
+ }
23
+ }
24
+
25
+ @Controller('/api')
26
+ class HelloController {
27
+ @Autowired()
28
+ private helloService!: HelloService;
29
+
30
+ @Get('/hello')
31
+ getHello() {
32
+ return this.helloService.getMessage();
33
+ }
34
+ }
35
+
36
+ const app = await Rikta.create({
37
+ port: 3000,
38
+ autowired: ['./src']
39
+ });
40
+ await app.listen();
41
+ ```
42
+
43
+ ## Features
44
+
45
+ - 🚀 Zero-Config Autowiring
46
+ - ⚡ Fastify Powered
47
+ - 🛡️ Type-Safe by Default
48
+ - 🔄 Hybrid Lifecycle
49
+ - 📦 Built-in Dependency Injection
50
+ - ✅ Zod Validation Integration
51
+
52
+ ## Provider Scopes
53
+
54
+ Rikta supports three provider scopes:
55
+
56
+ ```typescript
57
+ // Singleton (default) - shared instance
58
+ @Injectable()
59
+ class ConfigService {}
60
+
61
+ // Transient - new instance each time
62
+ @Injectable({ scope: 'transient' })
63
+ class RequestLogger {}
64
+
65
+ // Request - one instance per HTTP request
66
+ @Injectable({ scope: 'request' })
67
+ class RequestContext {}
68
+ ```
69
+
70
+ ## Strict Discovery Mode
71
+
72
+ Enable strict discovery to catch import errors early:
73
+
74
+ ```typescript
75
+ const app = await Rikta.create({
76
+ strictDiscovery: process.env.NODE_ENV !== 'production',
77
+ onDiscoveryError: (file, error) => {
78
+ console.warn(`Failed to import: ${file}`);
79
+ },
80
+ });
81
+ ```
82
+
83
+ ## EventBus
84
+
85
+ The EventBus provides pub/sub for lifecycle events:
86
+
87
+ ```typescript
88
+ import { Injectable, Autowired, EventBus } from '@riktajs/core';
89
+
90
+ @Injectable()
91
+ class MonitorService {
92
+ @Autowired()
93
+ private events!: EventBus;
94
+
95
+ onProviderInit() {
96
+ this.events.on('app:listen', ({ address }) => {
97
+ console.log(`Server at ${address}`);
98
+ });
99
+ }
100
+ }
101
+ ```
102
+
103
+ ## Interceptors
104
+
105
+ Interceptors allow you to bind extra logic before/after method execution:
106
+
107
+ ```typescript
108
+ import { Injectable, Interceptor, ExecutionContext, CallHandler, UseInterceptors } from '@riktajs/core';
109
+
110
+ @Injectable()
111
+ class LoggingInterceptor implements Interceptor {
112
+ async intercept(context: ExecutionContext, next: CallHandler): Promise<unknown> {
113
+ const start = Date.now();
114
+ const result = await next.handle();
115
+ console.log(`Request took ${Date.now() - start}ms`);
116
+ return result;
117
+ }
118
+ }
119
+
120
+ @Controller('/api')
121
+ @UseInterceptors(LoggingInterceptor)
122
+ class ApiController {
123
+ @Get('/data')
124
+ getData() {
125
+ return { data: 'example' };
126
+ }
127
+ }
128
+ ```
129
+
130
+ ## License
131
+
132
+ MIT
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { RiktaConfig, RiktaApplication } from './types';
2
+ import { RiktaConfig, RiktaApplication } from './types.js';
3
3
  export declare class RiktaFactory {
4
4
  static create(config?: RiktaConfig): Promise<RiktaApplication>;
5
5
  }
@@ -1,33 +1,27 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Rikta = exports.RiktaFactory = void 0;
7
- require("reflect-metadata");
8
- const fastify_1 = __importDefault(require("fastify"));
9
- const container_1 = require("./container/container");
10
- const router_1 = require("./router/router");
11
- const registry_1 = require("./registry");
12
- const discovery_1 = require("./discovery");
13
- const event_bus_1 = require("./lifecycle/event-bus");
14
- const on_decorator_1 = require("./lifecycle/on.decorator");
15
- const constants_1 = require("./constants");
16
- const exceptions_1 = require("./exceptions");
17
- const env_loader_1 = require("./config/env-loader");
18
- class RiktaFactory {
1
+ import 'reflect-metadata';
2
+ import Fastify from 'fastify';
3
+ import { Container } from './container/container.js';
4
+ import { Router } from './router/router.js';
5
+ import { registry } from './registry.js';
6
+ import { discoverModules, getCallerDirectory } from './discovery.js';
7
+ import { EventBus } from './lifecycle/event-bus.js';
8
+ import { ON_EVENT_METADATA } from './lifecycle/on.decorator.js';
9
+ import { DEFAULT_CONFIG, PROVIDER_METADATA, INJECTABLE_METADATA } from './constants.js';
10
+ import { GlobalExceptionFilter, createExceptionHandler, getCatchMetadata } from './exceptions/index.js';
11
+ import { loadEnvFiles } from './config/env-loader.js';
12
+ export class RiktaFactory {
19
13
  static async create(config = {}) {
20
- (0, env_loader_1.loadEnvFiles)();
14
+ loadEnvFiles();
21
15
  const silent = config.silent ?? false;
22
16
  if (!silent)
23
17
  console.log('\n🚀 Rikta Framework Starting...\n');
24
- const callerDir = (0, discovery_1.getCallerDirectory)();
18
+ const callerDir = getCallerDirectory();
25
19
  let discoveredFiles = [];
26
20
  if (!config.controllers && config.autowired !== false) {
27
21
  const patterns = Array.isArray(config.autowired) && config.autowired.length > 0
28
22
  ? config.autowired
29
23
  : ['./**'];
30
- discoveredFiles = await (0, discovery_1.discoverModules)({
24
+ discoveredFiles = await discoverModules({
31
25
  patterns,
32
26
  cwd: callerDir,
33
27
  strict: config.strictDiscovery ?? false,
@@ -39,8 +33,6 @@ class RiktaFactory {
39
33
  return app;
40
34
  }
41
35
  }
42
- exports.RiktaFactory = RiktaFactory;
43
- exports.Rikta = RiktaFactory;
44
36
  class RiktaApplicationImpl {
45
37
  server;
46
38
  container;
@@ -55,32 +47,32 @@ class RiktaApplicationImpl {
55
47
  constructor(config) {
56
48
  const silent = config.silent ?? false;
57
49
  this.config = {
58
- port: config.port ?? constants_1.DEFAULT_CONFIG.port,
59
- host: config.host ?? constants_1.DEFAULT_CONFIG.host,
60
- logger: config.logger ?? (silent ? false : constants_1.DEFAULT_CONFIG.logger),
61
- prefix: config.prefix ?? constants_1.DEFAULT_CONFIG.prefix,
50
+ port: config.port ?? DEFAULT_CONFIG.port,
51
+ host: config.host ?? DEFAULT_CONFIG.host,
52
+ logger: config.logger ?? (silent ? false : DEFAULT_CONFIG.logger),
53
+ prefix: config.prefix ?? DEFAULT_CONFIG.prefix,
62
54
  silent: silent,
63
55
  controllers: config.controllers,
64
56
  providers: config.providers,
65
57
  exceptionFilter: config.exceptionFilter,
66
58
  exceptionFilters: config.exceptionFilters,
67
59
  };
68
- this.server = (0, fastify_1.default)({ logger: this.config.logger });
69
- this.container = container_1.Container.getInstance();
70
- this.router = new router_1.Router(this.server, this.container, this.config.prefix);
71
- this.events = new event_bus_1.EventBus();
72
- this.container.registerInstance(event_bus_1.EventBus, this.events);
60
+ this.server = Fastify({ logger: this.config.logger });
61
+ this.container = Container.getInstance();
62
+ this.router = new Router(this.server, this.container, this.config.prefix);
63
+ this.events = new EventBus();
64
+ this.container.registerInstance(EventBus, this.events);
73
65
  this.setupExceptionHandler();
74
66
  }
75
67
  setupExceptionHandler() {
76
68
  const silent = this.config.silent ?? false;
77
- const globalFilter = new exceptions_1.GlobalExceptionFilter({
69
+ const globalFilter = new GlobalExceptionFilter({
78
70
  includeStack: this.config.exceptionFilter?.includeStack,
79
71
  logErrors: this.config.exceptionFilter?.logErrors ?? (silent ? false : true),
80
72
  });
81
73
  const customFilters = this.config.exceptionFilters ?? [];
82
74
  for (const FilterClass of customFilters) {
83
- const metadata = (0, exceptions_1.getCatchMetadata)(FilterClass);
75
+ const metadata = getCatchMetadata(FilterClass);
84
76
  const filterInstance = this.container.resolve(FilterClass);
85
77
  if (metadata && metadata.exceptions.length > 0) {
86
78
  for (const ExceptionType of metadata.exceptions) {
@@ -91,14 +83,14 @@ class RiktaApplicationImpl {
91
83
  this.customExceptionFilters.set(Error, filterInstance);
92
84
  }
93
85
  }
94
- this.server.setErrorHandler((0, exceptions_1.createExceptionHandler)(globalFilter, this.customExceptionFilters));
86
+ this.server.setErrorHandler(createExceptionHandler(globalFilter, this.customExceptionFilters));
95
87
  }
96
88
  async init(discoveredFiles = []) {
97
89
  await this.events.emit('app:discovery', { files: discoveredFiles });
98
90
  await this.processConfigProviders();
99
91
  await this.processCustomProviders();
100
92
  await this.events.emit('app:providers', {
101
- count: registry_1.registry.getCustomProviders().length
93
+ count: registry.getCustomProviders().length
102
94
  });
103
95
  const providers = this.getSortedProviders();
104
96
  const additionalProviders = this.config.providers ?? [];
@@ -108,7 +100,7 @@ class RiktaApplicationImpl {
108
100
  for (const { target, priority } of providers) {
109
101
  await this.initializeProvider(target, priority);
110
102
  }
111
- const controllers = this.config.controllers ?? registry_1.registry.getControllers();
103
+ const controllers = this.config.controllers ?? registry.getControllers();
112
104
  if (!this.config.silent)
113
105
  console.log('📡 Registering routes:');
114
106
  for (const controller of controllers) {
@@ -123,7 +115,7 @@ class RiktaApplicationImpl {
123
115
  console.log('\n✅ Rikta is ready\n');
124
116
  }
125
117
  async processConfigProviders() {
126
- const configProviders = registry_1.registry.getConfigProviderRegistrations();
118
+ const configProviders = registry.getConfigProviderRegistrations();
127
119
  if (configProviders.length === 0)
128
120
  return;
129
121
  for (const { token, providerClass } of configProviders) {
@@ -134,11 +126,11 @@ class RiktaApplicationImpl {
134
126
  }
135
127
  }
136
128
  async processCustomProviders() {
137
- const customProviders = registry_1.registry.getCustomProviders();
129
+ const customProviders = registry.getCustomProviders();
138
130
  if (customProviders.length === 0)
139
131
  return;
140
132
  for (const ProviderClass of customProviders) {
141
- const metadata = Reflect.getMetadata(constants_1.PROVIDER_METADATA, ProviderClass);
133
+ const metadata = Reflect.getMetadata(PROVIDER_METADATA, ProviderClass);
142
134
  if (!metadata)
143
135
  continue;
144
136
  const providerInstance = this.container.resolve(ProviderClass);
@@ -147,7 +139,7 @@ class RiktaApplicationImpl {
147
139
  }
148
140
  }
149
141
  getSortedProviders() {
150
- const providers = registry_1.registry.getProviders();
142
+ const providers = registry.getProviders();
151
143
  return providers
152
144
  .map(target => ({
153
145
  target,
@@ -156,7 +148,7 @@ class RiktaApplicationImpl {
156
148
  .sort((a, b) => b.priority - a.priority);
157
149
  }
158
150
  getProviderPriority(target) {
159
- const options = Reflect.getMetadata(constants_1.INJECTABLE_METADATA, target);
151
+ const options = Reflect.getMetadata(INJECTABLE_METADATA, target);
160
152
  return options?.priority ?? 0;
161
153
  }
162
154
  async initializeProvider(target, priority) {
@@ -170,7 +162,7 @@ class RiktaApplicationImpl {
170
162
  this.registerEventListeners(target, instance);
171
163
  }
172
164
  registerEventListeners(target, instance) {
173
- const metadata = Reflect.getMetadata(on_decorator_1.ON_EVENT_METADATA, target) ?? [];
165
+ const metadata = Reflect.getMetadata(ON_EVENT_METADATA, target) ?? [];
174
166
  for (const { event, methodName } of metadata) {
175
167
  const method = instance[methodName];
176
168
  if (typeof method === 'function') {
@@ -253,3 +245,4 @@ class RiktaApplicationImpl {
253
245
  this.router.clearAllCaches();
254
246
  }
255
247
  }
248
+ export { RiktaFactory as Rikta };
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractConfigProvider = exports.ConfigValidationException = void 0;
4
- const zod_1 = require("zod");
5
- const config_property_decorator_1 = require("../decorators/config-property.decorator");
6
- const env_loader_1 = require("./env-loader");
7
- class ConfigValidationException extends Error {
1
+ import { z } from 'zod';
2
+ import { getConfigPropertyMappings } from '../decorators/config-property.decorator.js';
3
+ import { loadEnvFiles } from './env-loader.js';
4
+ export class ConfigValidationException extends Error {
8
5
  errors;
9
6
  constructor(errors, providerName) {
10
7
  const errorMessages = errors.issues
@@ -16,11 +13,10 @@ class ConfigValidationException extends Error {
16
13
  this.name = 'ConfigValidationException';
17
14
  }
18
15
  }
19
- exports.ConfigValidationException = ConfigValidationException;
20
- class AbstractConfigProvider {
16
+ export class AbstractConfigProvider {
21
17
  _cache;
22
18
  constructor() {
23
- (0, env_loader_1.loadEnvFiles)();
19
+ loadEnvFiles();
24
20
  }
25
21
  validateAndCache() {
26
22
  if (this._cache) {
@@ -33,7 +29,7 @@ class AbstractConfigProvider {
33
29
  return this._cache;
34
30
  }
35
31
  catch (error) {
36
- if (error instanceof zod_1.z.ZodError) {
32
+ if (error instanceof z.ZodError) {
37
33
  throw new ConfigValidationException(error, this.constructor.name);
38
34
  }
39
35
  throw error;
@@ -41,7 +37,7 @@ class AbstractConfigProvider {
41
37
  }
42
38
  populate() {
43
39
  const config = this.validateAndCache();
44
- const mappings = (0, config_property_decorator_1.getConfigPropertyMappings)(this.constructor);
40
+ const mappings = getConfigPropertyMappings(this.constructor);
45
41
  for (const mapping of mappings) {
46
42
  const value = config[mapping.envKey];
47
43
  this[mapping.propertyKey] = value;
@@ -55,4 +51,3 @@ class AbstractConfigProvider {
55
51
  return config[key];
56
52
  }
57
53
  }
58
- exports.AbstractConfigProvider = AbstractConfigProvider;
@@ -1,31 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadEnvFiles = loadEnvFiles;
4
- exports.isEnvLoaded = isEnvLoaded;
5
- exports.resetEnvLoaded = resetEnvLoaded;
6
- const dotenv_1 = require("dotenv");
7
- const fs_1 = require("fs");
8
- const path_1 = require("path");
1
+ import { config as loadEnv } from 'dotenv';
2
+ import { existsSync } from 'fs';
3
+ import { resolve } from 'path';
9
4
  let envLoaded = false;
10
- function loadEnvFiles() {
5
+ export function loadEnvFiles() {
11
6
  if (envLoaded) {
12
7
  return;
13
8
  }
14
9
  const env = process.env.NODE_ENV || 'development';
15
10
  const cwd = process.cwd();
16
- const baseEnvPath = (0, path_1.resolve)(cwd, '.env');
17
- if ((0, fs_1.existsSync)(baseEnvPath)) {
18
- (0, dotenv_1.config)({ path: baseEnvPath, override: false });
11
+ const baseEnvPath = resolve(cwd, '.env');
12
+ if (existsSync(baseEnvPath)) {
13
+ loadEnv({ path: baseEnvPath, override: false });
19
14
  }
20
- const envSpecificPath = (0, path_1.resolve)(cwd, `.env.${env}`);
21
- if ((0, fs_1.existsSync)(envSpecificPath)) {
22
- (0, dotenv_1.config)({ path: envSpecificPath, override: true });
15
+ const envSpecificPath = resolve(cwd, `.env.${env}`);
16
+ if (existsSync(envSpecificPath)) {
17
+ loadEnv({ path: envSpecificPath, override: true });
23
18
  }
24
19
  envLoaded = true;
25
20
  }
26
- function isEnvLoaded() {
21
+ export function isEnvLoaded() {
27
22
  return envLoaded;
28
23
  }
29
- function resetEnvLoaded() {
24
+ export function resetEnvLoaded() {
30
25
  envLoaded = false;
31
26
  }
@@ -1,2 +1,2 @@
1
- export * from './abstract-config-provider';
2
- export * from './env-loader';
1
+ export * from './abstract-config-provider.js';
2
+ export * from './env-loader.js';
@@ -1,18 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./abstract-config-provider"), exports);
18
- __exportStar(require("./env-loader"), exports);
1
+ export * from './abstract-config-provider.js';
2
+ export * from './env-loader.js';
@@ -1,22 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_CONFIG = exports.ParamType = exports.CONFIG_PROPERTY_METADATA = exports.CONFIG_PROVIDER_METADATA = exports.PROVIDER_METADATA = exports.AUTOWIRED_METADATA = exports.ZOD_SCHEMA_METADATA = exports.INJECT_METADATA = exports.HEADERS_METADATA = exports.HTTP_CODE_METADATA = exports.MIDDLEWARE_METADATA = exports.INTERCEPTORS_METADATA = exports.GUARDS_METADATA = exports.PARAM_METADATA = exports.INJECTABLE_METADATA = exports.ROUTES_METADATA = exports.CONTROLLER_METADATA = void 0;
4
- exports.CONTROLLER_METADATA = Symbol.for('rikta:controller:metadata');
5
- exports.ROUTES_METADATA = Symbol.for('rikta:routes:metadata');
6
- exports.INJECTABLE_METADATA = Symbol.for('rikta:injectable:metadata');
7
- exports.PARAM_METADATA = Symbol.for('rikta:param:metadata');
8
- exports.GUARDS_METADATA = Symbol.for('rikta:guards:metadata');
9
- exports.INTERCEPTORS_METADATA = Symbol.for('rikta:interceptors:metadata');
10
- exports.MIDDLEWARE_METADATA = Symbol.for('rikta:middleware:metadata');
11
- exports.HTTP_CODE_METADATA = Symbol.for('rikta:http:code:metadata');
12
- exports.HEADERS_METADATA = Symbol.for('rikta:headers:metadata');
13
- exports.INJECT_METADATA = Symbol.for('rikta:inject:metadata');
14
- exports.ZOD_SCHEMA_METADATA = Symbol.for('rikta:zod:schema:metadata');
15
- exports.AUTOWIRED_METADATA = Symbol.for('rikta:autowired:metadata');
16
- exports.PROVIDER_METADATA = Symbol.for('rikta:provider:metadata');
17
- exports.CONFIG_PROVIDER_METADATA = Symbol('config:provider:metadata');
18
- exports.CONFIG_PROPERTY_METADATA = Symbol('config:property:metadata');
19
- var ParamType;
1
+ export const CONTROLLER_METADATA = Symbol.for('rikta:controller:metadata');
2
+ export const ROUTES_METADATA = Symbol.for('rikta:routes:metadata');
3
+ export const INJECTABLE_METADATA = Symbol.for('rikta:injectable:metadata');
4
+ export const PARAM_METADATA = Symbol.for('rikta:param:metadata');
5
+ export const GUARDS_METADATA = Symbol.for('rikta:guards:metadata');
6
+ export const INTERCEPTORS_METADATA = Symbol.for('rikta:interceptors:metadata');
7
+ export const MIDDLEWARE_METADATA = Symbol.for('rikta:middleware:metadata');
8
+ export const HTTP_CODE_METADATA = Symbol.for('rikta:http:code:metadata');
9
+ export const HEADERS_METADATA = Symbol.for('rikta:headers:metadata');
10
+ export const INJECT_METADATA = Symbol.for('rikta:inject:metadata');
11
+ export const ZOD_SCHEMA_METADATA = Symbol.for('rikta:zod:schema:metadata');
12
+ export const AUTOWIRED_METADATA = Symbol.for('rikta:autowired:metadata');
13
+ export const PROVIDER_METADATA = Symbol.for('rikta:provider:metadata');
14
+ export const CONFIG_PROVIDER_METADATA = Symbol('config:provider:metadata');
15
+ export const CONFIG_PROPERTY_METADATA = Symbol('config:property:metadata');
16
+ export var ParamType;
20
17
  (function (ParamType) {
21
18
  ParamType["BODY"] = "body";
22
19
  ParamType["QUERY"] = "query";
@@ -25,8 +22,8 @@ var ParamType;
25
22
  ParamType["REQUEST"] = "request";
26
23
  ParamType["REPLY"] = "reply";
27
24
  ParamType["CONTEXT"] = "context";
28
- })(ParamType || (exports.ParamType = ParamType = {}));
29
- exports.DEFAULT_CONFIG = {
25
+ })(ParamType || (ParamType = {}));
26
+ export const DEFAULT_CONFIG = {
30
27
  port: 3000,
31
28
  host: '0.0.0.0',
32
29
  logger: true,
@@ -1,4 +1,4 @@
1
- import { Constructor } from '../types';
1
+ import { Constructor } from '../types.js';
2
2
  export declare const IMPLEMENTS_METADATA: unique symbol;
3
3
  export declare const PRIMARY_METADATA: unique symbol;
4
4
  export declare function isAbstractClass(target: unknown): target is Constructor;