aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api/configuration/+server.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-02-11 15:45:56 -0800
committerFuwn <[email protected]>2024-02-11 15:45:56 -0800
commita8417ece5d5d0f75a6215dbfd47f0cc2f691defd (patch)
tree3b877afff20635f8acdcfe0fb09cb1c8581c4de4 /src/routes/api/configuration/+server.ts
parentrefactor(database): rename event badges (diff)
downloaddue.moe-a8417ece5d5d0f75a6215dbfd47f0cc2f691defd.tar.xz
due.moe-a8417ece5d5d0f75a6215dbfd47f0cc2f691defd.zip
feat(database): config sync scaffolding
Diffstat (limited to 'src/routes/api/configuration/+server.ts')
-rw-r--r--src/routes/api/configuration/+server.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/routes/api/configuration/+server.ts b/src/routes/api/configuration/+server.ts
new file mode 100644
index 00000000..a42d9c54
--- /dev/null
+++ b/src/routes/api/configuration/+server.ts
@@ -0,0 +1,23 @@
+import { getUserConfiguration, setUserConfiguration } from '$lib/Database/userConfiguration.js';
+
+export const GET = async ({ url }) =>
+ Response.json(await getUserConfiguration(Number(url.searchParams.get('id') || 0)), {
+ headers: {
+ 'Access-Control-Allow-Origin': 'https://due.moe'
+ }
+ });
+
+export const PUT = async ({ url, request }) =>
+ Response.json(
+ await setUserConfiguration(Number(url.searchParams.get('id') || 0), {
+ configuration: await request.json(),
+ updated_at: new Date().toISOString(),
+ user_id: Number(url.searchParams.get('id') || 0),
+ created_at: new Date().toISOString()
+ }),
+ {
+ headers: {
+ 'Access-Control-Allow-Origin': 'https://due.moe'
+ }
+ }
+ );