This commit is contained in:
Andras Bacsai
2021-05-16 21:54:44 +02:00
committed by GitHub
parent 23a4ebb74a
commit adcd68c1ab
68 changed files with 2466 additions and 1194 deletions

View File

@@ -0,0 +1,52 @@
import { saveServerLog } from '$lib/api/applications/logging';
import Settings from '$models/Settings';
import type { Request } from '@sveltejs/kit';
const applicationName = 'coolify';
export async function get(request: Request) {
try {
const settings = await Settings.findOne({ applicationName }).select('-_id -__v');
const payload = {
applicationName,
allowRegistration: false,
...settings._doc
};
return {
status: 200,
body: {
...payload
}
};
} catch (error) {
await saveServerLog(error);
return {
status: 500,
body: {
error: error.message || error
}
};
}
}
export async function post(request: Request) {
try {
const settings = await Settings.findOneAndUpdate(
{ applicationName },
{ applicationName, ...request.body },
{ upsert: true, new: true }
).select('-_id -__v');
return {
status: 201,
body: {
...settings._doc
}
};
} catch (error) {
await saveServerLog(error);
return {
status: 500,
body: {
error: error.message || error
}
};
}
}