1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-17 01:17:29 +02:00

fix: introduce settingService

This commit is contained in:
Ivar Conradi Østhus 2021-04-22 22:54:08 +02:00
parent b33e8e23f0
commit 424d4e209e
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09
4 changed files with 34 additions and 1 deletions

View File

@ -99,7 +99,7 @@ const defaultAuthentication: IAuthOption = {
enableApiToken: safeBoolean(process.env.AUTH_ENABLE_API_TOKEN, true),
type: authTypeFromString(process.env.AUTH_TYPE),
customAuthHandler: () => {},
createAdminUser: false,
createAdminUser: true,
};
const defaultImport: IImportOption = {

View File

@ -20,6 +20,7 @@ const { AccessService } = require('./access-service');
const { ApiTokenService } = require('./api-token-service');
const UserService = require('./user-service');
const ResetTokenService = require('./reset-token-service');
const SettingService = require('./setting-service');
export const createServices = (
stores: IUnleashStores,
@ -51,6 +52,7 @@ export const createServices = (
});
const versionService = new VersionService(stores, config);
const healthService = new HealthService(stores, config);
const settingService = new SettingService(stores, config);
return {
accessService,
@ -71,6 +73,7 @@ export const createServices = (
userService,
resetTokenService,
eventService,
settingService,
};
};

View File

@ -0,0 +1,28 @@
import { IUnleashConfig } from '../types/option';
import { IUnleashStores } from '../types/stores';
import { Logger } from '../logger';
import SettingStore from '../db/setting-store';
export default class SettingService {
private logger: Logger;
private settingStore: SettingStore;
constructor(
{ settingStore }: Pick<IUnleashStores, 'settingStore'>,
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
) {
this.logger = getLogger('services/setting-service.ts');
this.settingStore = settingStore;
}
async get(id: string): Promise<object> {
return this.settingStore.get(id);
}
async insert(id: string, value: object): Promise<void> {
return this.settingStore.insert(id, value);
}
}
module.exports = SettingService;

View File

@ -16,6 +16,7 @@ import ResetTokenService from '../services/reset-token-service';
import FeatureTypeService from '../services/feature-type-service';
import EventService from '../services/event-service';
import HealthService from '../services/health-service';
import SettingService from '../services/setting-service';
export interface IUnleashServices {
accessService: AccessService;
@ -30,6 +31,7 @@ export interface IUnleashServices {
healthService: HealthService;
projectService: ProjectService;
resetTokenService: ResetTokenService;
settingService: SettingService;
stateService: StateService;
strategyService: StrategyService;
tagTypeService: TagTypeService;