-
Notifications
You must be signed in to change notification settings - Fork 70
/
component.ts
43 lines (39 loc) · 1.24 KB
/
component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2023 Sourcefuse Technologies
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
import {
Component,
ProviderMap,
Binding,
inject,
CoreBindings,
ServiceOrProviderClass,
} from '@loopback/core';
import {RestApplication} from '@loopback/rest';
import {CoreComponent} from '@sourceloop/core';
import {StrategyBindings} from './keys';
import {FeatureToggleActionMiddlewareInterceptor} from './middlewares';
import {
FeatureFlagActionProvider,
FeatureFlagMetadataProvider,
} from './providers';
import {FeatureHandlerService} from './services';
export class FeatureToggleComponent implements Component {
providers?: ProviderMap;
bindings?: Binding[];
services?: ServiceOrProviderClass[];
constructor(
@inject(CoreBindings.APPLICATION_INSTANCE)
private readonly application: RestApplication,
) {
// Mount core component
this.application.component(CoreComponent);
this.application.middleware(FeatureToggleActionMiddlewareInterceptor);
this.providers = {
[StrategyBindings.FEATURE_FLAG_ACTION.key]: FeatureFlagActionProvider,
[StrategyBindings.METADATA.key]: FeatureFlagMetadataProvider,
};
this.services = [FeatureHandlerService];
}
}