| | | 1 | | import { Container } from 'inversify'; |
| | | 2 | | import type { MapFileConfig } from '../../core/domain/MapFileConfig.js'; |
| | | 3 | | import type { ISecretMasker } from '../../core/domain/ports/ISecretMasker.js'; |
| | | 4 | | import { GitHubActionsSecretMasker } from '../../core/infrastructure/github/GitHubActionsSecretMasker.js'; |
| | | 5 | | import { TYPES } from '../../core/types.js'; |
| | | 6 | | import { |
| | | 7 | | configureApplicationServices, |
| | | 8 | | configureInfrastructureServices, |
| | | 9 | | type InfrastructureOptions, |
| | | 10 | | } from '../shared/ContainerConfiguration.js'; |
| | | 11 | | |
| | | 12 | | export class Startup { |
| | | 13 | | private readonly container: Container; |
| | | 14 | | |
| | | 15 | | constructor() { |
| | 15 | 16 | | this.container = new Container(); |
| | | 17 | | } |
| | | 18 | | |
| | | 19 | | static build(): Startup { |
| | 15 | 20 | | return new Startup(); |
| | | 21 | | } |
| | | 22 | | |
| | | 23 | | configureServices(): this { |
| | 15 | 24 | | configureApplicationServices(this.container); |
| | 15 | 25 | | return this; |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | configureInfrastructure( |
| | | 29 | | config?: MapFileConfig, |
| | | 30 | | options?: InfrastructureOptions, |
| | | 31 | | ): this { |
| | 15 | 32 | | if (!this.container.isBound(TYPES.ISecretMasker)) { |
| | 15 | 33 | | this.container |
| | | 34 | | .bind<ISecretMasker>(TYPES.ISecretMasker) |
| | | 35 | | .to(GitHubActionsSecretMasker) |
| | | 36 | | .inSingletonScope(); |
| | | 37 | | } |
| | 15 | 38 | | configureInfrastructureServices(this.container, config, options); |
| | 15 | 39 | | return this; |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | create(): Container { |
| | 15 | 43 | | return this.container; |
| | | 44 | | } |
| | | 45 | | |
| | | 46 | | getServiceProvider(): Container { |
| | 0 | 47 | | return this.container; |
| | | 48 | | } |
| | | 49 | | } |