feat: write POST /v1/admin/apps/:key/config

This commit is contained in:
Ali BARIN
2024-08-27 12:44:14 +00:00
parent 87b26b6342
commit af4c1f08ec
4 changed files with 117 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { renderError, renderObject } from '../../../../../helpers/renderer.js';
import AppConfig from '../../../../../models/app-config.js';
export default async (request, response) => {
const appKey = request.params.appKey;
const appConfig = await AppConfig.query()
.findOne({ key: appKey });
if (appConfig) {
return renderError(response, [{ general: ['App config already exists.'] }], 409);
}
const createdAppConfig = await AppConfig
.query()
.insertAndFetch(appConfigParams(request));
renderObject(response, createdAppConfig, { status: 201 });
};
const appConfigParams = (request) => {
const { allowCustomConnection, shared, disabled } = request.body;
return {
key: request.params.appKey,
allowCustomConnection,
shared,
disabled,
};
};