33 lines
978 B
TypeScript
33 lines
978 B
TypeScript
import { jsonBody } from '$lib/server/request-body.js';
|
|
import { isHttpError, json } from '@sveltejs/kit';
|
|
import {
|
|
retentionPreview,
|
|
retentionControls,
|
|
sampleRetentionPreview,
|
|
setRetentionControl
|
|
} from '$lib/server/retention.js';
|
|
import { gameFileRetentionPreview } from '$lib/server/game-files/index.js';
|
|
|
|
export function GET() {
|
|
return json(
|
|
{
|
|
policies: [
|
|
...retentionPreview(),
|
|
...sampleRetentionPreview(),
|
|
...gameFileRetentionPreview()
|
|
],
|
|
controls: retentionControls()
|
|
},
|
|
{ headers: { 'Cache-Control': 'no-store' } }
|
|
);
|
|
}
|
|
export async function POST({ request }: { request: Request }) {
|
|
try {
|
|
setRetentionControl(await jsonBody(request));
|
|
return json({ ok: true });
|
|
} catch (error) {
|
|
if (isHttpError(error, 413)) throw error;
|
|
return json({ error: (error as Error).message }, { status: 400 });
|
|
}
|
|
}
|