mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-01 01:18:10 +02:00
If you have SDK tokens scoped to projects that are deleted, you should not get access to any flags with those. --------- Co-authored-by: David Leek <david@getunleash.io>
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
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,
|
|
config.flagResolver,
|
|
);
|
|
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,
|
|
};
|
|
};
|