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:
parent
b33e8e23f0
commit
424d4e209e
@ -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 = {
|
||||
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
|
28
src/lib/services/setting-service.ts
Normal file
28
src/lib/services/setting-service.ts
Normal 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;
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user