aboutsummaryrefslogtreecommitdiff
path: root/src/routes/+page.server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/+page.server.ts')
-rw-r--r--src/routes/+page.server.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts
new file mode 100644
index 0000000..fc160df
--- /dev/null
+++ b/src/routes/+page.server.ts
@@ -0,0 +1,20 @@
+import { fail } from '@sveltejs/kit';
+import { loadOverview } from '$lib/server/services/routines';
+import { add as addProject } from '$lib/server/services/projects';
+import { parseFormString } from '$lib/server/services/validation';
+import type { Actions, PageServerLoad } from './$types';
+
+export const load: PageServerLoad = async () => {
+ return loadOverview(Date.now());
+};
+
+export const actions: Actions = {
+ addProject: async ({ request }) => {
+ const name = parseFormString((await request.formData()).get('name'));
+ if (!name) {
+ return fail(400, { error: 'Le nom est requis' });
+ }
+ await addProject(name);
+ return { success: true };
+ },
+};