mirror of
https://github.com/ershisan99/coolify.git
synced 2026-01-23 05:12:03 +00:00
v1.0.13 (#46)
This commit is contained in:
52
src/routes/api/v1/settings/index.ts
Normal file
52
src/routes/api/v1/settings/index.ts
Normal 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
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user