-
-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: extract api token service composition root; place it in /featu…
…res (#7519) This is a refactoring task, creating an ApiTokenService composition root in /features.
- Loading branch information
1 parent
57c1a6e
commit 6d91380
Showing
12 changed files
with
182 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type { Db, IUnleashConfig } from '../../server-impl'; | ||
import EnvironmentStore from '../project-environments/environment-store'; | ||
import { ApiTokenService, type EventService } from '../../services'; | ||
import FakeEnvironmentStore from '../project-environments/fake-environment-store'; | ||
import type { IEnvironmentStore } from '../../types'; | ||
import { | ||
createEventsService, | ||
createFakeEventsService, | ||
} from '../events/createEventsService'; | ||
import FakeApiTokenStore from '../../../test/fixtures/fake-api-token-store'; | ||
import { ApiTokenStore } from '../../db/api-token-store'; | ||
|
||
export const createApiTokenService = ( | ||
db: Db, | ||
config: IUnleashConfig, | ||
): ApiTokenService => { | ||
const { eventBus, getLogger } = config; | ||
const apiTokenStore = new ApiTokenStore(db, eventBus, getLogger); | ||
const environmentStore = new EnvironmentStore(db, eventBus, getLogger); | ||
const eventService = createEventsService(db, config); | ||
|
||
return new ApiTokenService( | ||
{ apiTokenStore, environmentStore }, | ||
config, | ||
eventService, | ||
); | ||
}; | ||
|
||
export const createFakeApiTokenService = ( | ||
config: IUnleashConfig, | ||
): { | ||
apiTokenService: ApiTokenService; | ||
eventService: EventService; | ||
apiTokenStore: FakeApiTokenStore; | ||
environmentStore: IEnvironmentStore; | ||
} => { | ||
const apiTokenStore = new FakeApiTokenStore(); | ||
const environmentStore = new FakeEnvironmentStore(); | ||
const eventService = createFakeEventsService(config); | ||
|
||
const apiTokenService = new ApiTokenService( | ||
{ apiTokenStore, environmentStore }, | ||
config, | ||
eventService, | ||
); | ||
|
||
return { | ||
apiTokenService, | ||
apiTokenStore, | ||
eventService, | ||
environmentStore, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.