chore: move config behind checks (#1211)

This commit is contained in:
Ali BARIN
2023-08-11 22:32:13 +02:00
committed by GitHub
parent a6a124d2e6
commit 25983e046c
8 changed files with 13 additions and 8 deletions

View File

@@ -0,0 +1,34 @@
import { hasValidLicense } from '../../helpers/license.ee';
import Config from '../../models/config';
import Context from '../../types/express/context';
type Params = {
keys: string[];
};
const getConfig = async (
_parent: unknown,
params: Params,
context: Context
) => {
if (!await hasValidLicense()) return {};
const configQuery = Config
.query();
if (Array.isArray(params.keys)) {
configQuery.whereIn('key', params.keys);
}
const config = await configQuery;
return config.reduce((computedConfig, configEntry) => {
const { key, value } = configEntry;
computedConfig[key] = value?.data;
return computedConfig;
}, {} as Record<string, unknown>);
};
export default getConfig;