feat(config): incorporate static config as virtual attributes
This commit is contained in:
@@ -1,19 +1,8 @@
|
||||
import appConfig from '../../../../config/app.js';
|
||||
import Config from '../../../../models/config.js';
|
||||
import { renderObject } from '../../../../helpers/renderer.js';
|
||||
|
||||
export default async (request, response) => {
|
||||
const staticConfig = {
|
||||
disableNotificationsPage: appConfig.disableNotificationsPage,
|
||||
disableFavicon: appConfig.disableFavicon,
|
||||
additionalDrawerLink: appConfig.additionalDrawerLink,
|
||||
additionalDrawerLinkIcon: appConfig.additionalDrawerLinkIcon,
|
||||
additionalDrawerLinkText: appConfig.additionalDrawerLinkText,
|
||||
};
|
||||
|
||||
const dynamicConfig = await Config.get();
|
||||
|
||||
const dynamicAndStaticConfig = Object.assign(dynamicConfig, staticConfig);
|
||||
|
||||
renderObject(response, dynamicAndStaticConfig);
|
||||
const config = await Config.get();
|
||||
|
||||
renderObject(response, config);
|
||||
};
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import appConfig from '../config/app.js';
|
||||
import Base from './base.js';
|
||||
|
||||
class Config extends Base {
|
||||
@@ -19,6 +20,36 @@ class Config extends Base {
|
||||
},
|
||||
};
|
||||
|
||||
static get virtualAttributes() {
|
||||
return [
|
||||
'disableNotificationsPage',
|
||||
'disableFavicon',
|
||||
'additionalDrawerLink',
|
||||
'additionalDrawerLinkIcon',
|
||||
'additionalDrawerLinkText',
|
||||
];
|
||||
}
|
||||
|
||||
get disableNotificationsPage() {
|
||||
return appConfig.disableNotificationsPage;
|
||||
}
|
||||
|
||||
get disableFavicon() {
|
||||
return appConfig.disableFavicon;
|
||||
}
|
||||
|
||||
get additionalDrawerLink() {
|
||||
return appConfig.additionalDrawerLink;
|
||||
}
|
||||
|
||||
get additionalDrawerLinkIcon() {
|
||||
return appConfig.additionalDrawerLinkIcon;
|
||||
}
|
||||
|
||||
get additionalDrawerLinkText() {
|
||||
return appConfig.additionalDrawerLinkText;
|
||||
}
|
||||
|
||||
static async get() {
|
||||
const existingConfig = await this.query().limit(1).first();
|
||||
|
||||
|
Reference in New Issue
Block a user