Explicitely define server load and action types

This commit is contained in:
Thilo Hohlt
2024-08-05 14:38:44 +02:00
parent 2b3f0a80d2
commit fa500cf376
20 changed files with 55 additions and 27 deletions

View File

@@ -1,6 +1,7 @@
import { handleFileUpload } from "$lib/server/utils.js";
import type { Actions, PageServerLoad } from "./$types";
export const load = async ({ parent, params, cookies, fetch }) => {
export const load: PageServerLoad = async ({ parent, params, cookies, fetch }) => {
const articleData = await fetch(`http://localhost:3000/article?id=eq.${params.articleId}`, {
method: "GET",
headers: {
@@ -16,7 +17,7 @@ export const load = async ({ parent, params, cookies, fetch }) => {
return { website, article };
};
export const actions = {
export const actions: Actions = {
default: async ({ fetch, cookies, request, params, locals }) => {
const data = await request.formData();

View File

@@ -3,8 +3,9 @@
import WebsiteEditor from "$lib/components/WebsiteEditor.svelte";
import { ALLOWED_MIME_TYPES } from "$lib/utils";
import SuccessOrError from "$lib/components/SuccessOrError.svelte";
import type { ActionData, PageServerData } from "./$types";
const { data, form } = $props();
const { data, form } = $props<{ data: PageServerData; form: ActionData }>();
</script>
<SuccessOrError success={form?.success} message={form?.message} />