refactor: Remove redundant context variable from getConfig
This commit is contained in:
@@ -1,26 +1,20 @@
|
|||||||
import { hasValidLicense } from '../../helpers/license.ee';
|
import { hasValidLicense } from '../../helpers/license.ee';
|
||||||
import Config from '../../models/config';
|
import Config from '../../models/config';
|
||||||
import Context from '../../types/express/context';
|
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
keys: string[];
|
keys: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getConfig = async (
|
const getConfig = async (_parent: unknown, params: Params) => {
|
||||||
_parent: unknown,
|
if (!(await hasValidLicense())) return {};
|
||||||
params: Params,
|
|
||||||
context: Context
|
|
||||||
) => {
|
|
||||||
if (!await hasValidLicense()) return {};
|
|
||||||
|
|
||||||
const configQuery = Config
|
const configQuery = Config.query();
|
||||||
.query();
|
|
||||||
|
|
||||||
if (Array.isArray(params.keys)) {
|
if (Array.isArray(params.keys)) {
|
||||||
configQuery.whereIn('key', params.keys);
|
configQuery.whereIn('key', params.keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = await configQuery;
|
const config = await configQuery.orderBy('key', 'asc');
|
||||||
|
|
||||||
return config.reduce((computedConfig, configEntry) => {
|
return config.reduce((computedConfig, configEntry) => {
|
||||||
const { key, value } = configEntry;
|
const { key, value } = configEntry;
|
||||||
|
Reference in New Issue
Block a user