@velajs/vela 0.4.2 → 0.5.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.
- package/dist/cache/cache.module.d.ts +4 -1
- package/dist/cache/cache.module.js +51 -9
- package/dist/config/config.module.d.ts +4 -1
- package/dist/config/config.module.js +40 -3
- package/dist/config/config.types.d.ts +1 -0
- package/dist/constants.d.ts +6 -1
- package/dist/constants.js +5 -0
- package/dist/container/container.d.ts +4 -0
- package/dist/container/container.js +52 -15
- package/dist/container/decorators.d.ts +3 -1
- package/dist/container/decorators.js +27 -6
- package/dist/container/index.d.ts +4 -2
- package/dist/container/index.js +4 -2
- package/dist/container/mixin.d.ts +24 -0
- package/dist/container/mixin.js +26 -0
- package/dist/container/module-ref.d.ts +21 -0
- package/dist/container/module-ref.js +48 -0
- package/dist/container/types.d.ts +10 -3
- package/dist/container/types.js +9 -0
- package/dist/cors/cors.module.js +2 -2
- package/dist/factory.js +36 -13
- package/dist/fetch/fetch.module.d.ts +6 -0
- package/dist/fetch/fetch.module.js +77 -0
- package/dist/fetch/fetch.service.d.ts +24 -0
- package/dist/fetch/fetch.service.js +145 -0
- package/dist/fetch/fetch.types.d.ts +24 -0
- package/dist/fetch/fetch.types.js +1 -0
- package/dist/fetch/index.d.ts +3 -0
- package/dist/fetch/index.js +2 -0
- package/dist/http/decorators.d.ts +64 -0
- package/dist/http/decorators.js +89 -1
- package/dist/http/index.d.ts +3 -1
- package/dist/http/index.js +2 -1
- package/dist/http/middleware-consumer.d.ts +36 -0
- package/dist/http/middleware-consumer.js +71 -0
- package/dist/http/route.manager.d.ts +13 -1
- package/dist/http/route.manager.js +153 -53
- package/dist/index.d.ts +11 -6
- package/dist/index.js +7 -4
- package/dist/metadata.d.ts +1 -1
- package/dist/module/decorators.d.ts +1 -0
- package/dist/module/decorators.js +24 -8
- package/dist/module/index.d.ts +2 -2
- package/dist/module/index.js +1 -1
- package/dist/module/module-loader.d.ts +9 -1
- package/dist/module/module-loader.js +107 -11
- package/dist/module/types.d.ts +13 -3
- package/dist/pipeline/index.d.ts +3 -2
- package/dist/pipeline/index.js +1 -1
- package/dist/pipeline/pipes.d.ts +22 -0
- package/dist/pipeline/pipes.js +50 -0
- package/dist/pipeline/tokens.d.ts +1 -1
- package/dist/pipeline/tokens.js +1 -1
- package/dist/pipeline/types.d.ts +16 -0
- package/dist/registry/metadata.registry.d.ts +7 -6
- package/dist/registry/metadata.registry.js +13 -0
- package/dist/registry/types.d.ts +1 -0
- package/dist/schedule/schedule.executor.d.ts +11 -2
- package/dist/schedule/schedule.executor.js +134 -19
- package/dist/schedule/schedule.module.d.ts +4 -1
- package/dist/schedule/schedule.module.js +39 -7
- package/dist/testing/testing.builder.js +31 -17
- package/dist/throttler/throttler.module.d.ts +2 -1
- package/dist/throttler/throttler.module.js +47 -9
- package/package.json +1 -1
|
@@ -4,18 +4,22 @@ import { MetadataRegistry } from "../registry/metadata.registry.js";
|
|
|
4
4
|
import { ScheduleExecutor } from "./schedule.executor.js";
|
|
5
5
|
import { ScheduleRegistry } from "./schedule.registry.js";
|
|
6
6
|
import { SCHEDULE_MODULE_OPTIONS } from "./schedule.tokens.js";
|
|
7
|
+
function makeScheduleModuleClass() {
|
|
8
|
+
const moduleClass = class ScheduleDynamicModule {
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(moduleClass, 'name', {
|
|
11
|
+
value: 'ScheduleModule'
|
|
12
|
+
});
|
|
13
|
+
defineMetadata(METADATA_KEYS.MODULE, true, moduleClass);
|
|
14
|
+
return moduleClass;
|
|
15
|
+
}
|
|
7
16
|
export class ScheduleModule {
|
|
8
17
|
static forRoot(options = {}) {
|
|
9
18
|
const { enableTimers = false } = options;
|
|
10
|
-
const moduleClass =
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(moduleClass, 'name', {
|
|
13
|
-
value: 'ScheduleModule'
|
|
14
|
-
});
|
|
15
|
-
defineMetadata(METADATA_KEYS.MODULE, true, moduleClass);
|
|
19
|
+
const moduleClass = makeScheduleModuleClass();
|
|
16
20
|
const providers = [
|
|
17
21
|
{
|
|
18
|
-
|
|
22
|
+
provide: SCHEDULE_MODULE_OPTIONS,
|
|
19
23
|
useValue: options
|
|
20
24
|
},
|
|
21
25
|
ScheduleRegistry
|
|
@@ -36,4 +40,32 @@ export class ScheduleModule {
|
|
|
36
40
|
providers
|
|
37
41
|
};
|
|
38
42
|
}
|
|
43
|
+
static forRootAsync(options) {
|
|
44
|
+
const { enableTimers = false } = options;
|
|
45
|
+
const moduleClass = makeScheduleModuleClass();
|
|
46
|
+
const providers = [
|
|
47
|
+
{
|
|
48
|
+
provide: SCHEDULE_MODULE_OPTIONS,
|
|
49
|
+
useFactory: options.useFactory,
|
|
50
|
+
inject: options.inject ?? []
|
|
51
|
+
},
|
|
52
|
+
ScheduleRegistry
|
|
53
|
+
];
|
|
54
|
+
const exports = [
|
|
55
|
+
SCHEDULE_MODULE_OPTIONS,
|
|
56
|
+
ScheduleRegistry
|
|
57
|
+
];
|
|
58
|
+
if (enableTimers) {
|
|
59
|
+
providers.push(ScheduleExecutor);
|
|
60
|
+
exports.push(ScheduleExecutor);
|
|
61
|
+
}
|
|
62
|
+
MetadataRegistry.setModuleOptions(moduleClass, {
|
|
63
|
+
imports: options.imports ?? [],
|
|
64
|
+
exports
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
module: moduleClass,
|
|
68
|
+
providers
|
|
69
|
+
};
|
|
70
|
+
}
|
|
39
71
|
}
|
|
@@ -19,7 +19,7 @@ export class OverrideBy {
|
|
|
19
19
|
this.builder['addOverride']({
|
|
20
20
|
token: this.token,
|
|
21
21
|
provider: {
|
|
22
|
-
|
|
22
|
+
provide: this.token,
|
|
23
23
|
useValue: value
|
|
24
24
|
}
|
|
25
25
|
});
|
|
@@ -29,8 +29,8 @@ export class OverrideBy {
|
|
|
29
29
|
this.builder['addOverride']({
|
|
30
30
|
token: this.token,
|
|
31
31
|
provider: {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
provide: this.token,
|
|
33
|
+
useClass: cls
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
return this.builder;
|
|
@@ -39,7 +39,7 @@ export class OverrideBy {
|
|
|
39
39
|
this.builder['addOverride']({
|
|
40
40
|
token: this.token,
|
|
41
41
|
provider: {
|
|
42
|
-
|
|
42
|
+
provide: this.token,
|
|
43
43
|
useFactory: options.factory,
|
|
44
44
|
inject: options.inject
|
|
45
45
|
}
|
|
@@ -91,7 +91,7 @@ export class TestingModuleBuilder {
|
|
|
91
91
|
// Bootstrap (mirrors VelaFactory.create)
|
|
92
92
|
const container = new Container();
|
|
93
93
|
container.register({
|
|
94
|
-
|
|
94
|
+
provide: Container,
|
|
95
95
|
useValue: container
|
|
96
96
|
});
|
|
97
97
|
// Register overrides BEFORE module loading so ModuleLoader skips originals
|
|
@@ -102,24 +102,38 @@ export class TestingModuleBuilder {
|
|
|
102
102
|
ComponentManager.init(container);
|
|
103
103
|
const loader = new ModuleLoader(container, routeManager);
|
|
104
104
|
loader.load(TestRootModule);
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
routeManager.
|
|
105
|
+
const appGuards = loader.getAppProviderTokens(APP_GUARD);
|
|
106
|
+
if (appGuards.length > 0) {
|
|
107
|
+
routeManager.useGlobalGuardTokens(...appGuards);
|
|
108
|
+
} else if (container.has(APP_GUARD)) {
|
|
109
|
+
routeManager.useGlobalGuardTokens(APP_GUARD);
|
|
108
110
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
const appPipes = loader.getAppProviderTokens(APP_PIPE);
|
|
112
|
+
if (appPipes.length > 0) {
|
|
113
|
+
routeManager.useGlobalPipeTokens(...appPipes);
|
|
114
|
+
} else if (container.has(APP_PIPE)) {
|
|
115
|
+
routeManager.useGlobalPipeTokens(APP_PIPE);
|
|
111
116
|
}
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
const appInterceptors = loader.getAppProviderTokens(APP_INTERCEPTOR);
|
|
118
|
+
if (appInterceptors.length > 0) {
|
|
119
|
+
routeManager.useGlobalInterceptorTokens(...appInterceptors);
|
|
120
|
+
} else if (container.has(APP_INTERCEPTOR)) {
|
|
121
|
+
routeManager.useGlobalInterceptorTokens(APP_INTERCEPTOR);
|
|
114
122
|
}
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
const appFilters = loader.getAppProviderTokens(APP_FILTER);
|
|
124
|
+
if (appFilters.length > 0) {
|
|
125
|
+
routeManager.useGlobalFilterTokens(...appFilters);
|
|
126
|
+
} else if (container.has(APP_FILTER)) {
|
|
127
|
+
routeManager.useGlobalFilterTokens(APP_FILTER);
|
|
117
128
|
}
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
const appMiddleware = loader.getAppProviderTokens(APP_MIDDLEWARE);
|
|
130
|
+
if (appMiddleware.length > 0) {
|
|
131
|
+
routeManager.useGlobalMiddlewareTokens(...appMiddleware);
|
|
132
|
+
} else if (container.has(APP_MIDDLEWARE)) {
|
|
133
|
+
routeManager.useGlobalMiddlewareTokens(APP_MIDDLEWARE);
|
|
120
134
|
}
|
|
121
135
|
const app = new VelaApplication(container, routeManager);
|
|
122
|
-
const instances = loader.resolveAllInstances();
|
|
136
|
+
const instances = await loader.resolveAllInstances();
|
|
123
137
|
app.setInstances(instances);
|
|
124
138
|
await app.callOnModuleInit();
|
|
125
139
|
await app.callOnApplicationBootstrap();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { DynamicModule } from '../module/types';
|
|
1
|
+
import type { AsyncModuleOptions, DynamicModule } from '../module/types';
|
|
2
2
|
import type { ThrottlerModuleOptions } from './throttler.types';
|
|
3
3
|
export declare class ThrottlerModule {
|
|
4
4
|
static forRoot(options: ThrottlerModuleOptions): DynamicModule;
|
|
5
|
+
static forRootAsync(options: AsyncModuleOptions<ThrottlerModuleOptions>): DynamicModule;
|
|
5
6
|
}
|
|
@@ -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 =
|
|
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
|
-
|
|
29
|
+
provide: THROTTLER_OPTIONS,
|
|
26
30
|
useValue: options
|
|
27
31
|
},
|
|
28
32
|
{
|
|
29
|
-
|
|
33
|
+
provide: THROTTLER_STORAGE,
|
|
30
34
|
useValue: options.storage ?? new ThrottlerStorage()
|
|
31
35
|
},
|
|
32
36
|
ThrottlerGuard,
|
|
33
37
|
{
|
|
34
|
-
|
|
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
|
];
|