mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Add TypeScript definitions via pg-to-ts and refactor migrations
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { Actions, PageServerLoad } from "./$types";
|
||||
import { API_BASE_PREFIX } from "$lib/server/utils";
|
||||
import type { Article, ArticleInput, DocsCategory } from "$lib/db-schema";
|
||||
|
||||
export const load: PageServerLoad = async ({ params, fetch, cookies, url, parent, locals }) => {
|
||||
const searchQuery = url.searchParams.get("article_search_query");
|
||||
@@ -54,7 +55,7 @@ export const load: PageServerLoad = async ({ params, fetch, cookies, url, parent
|
||||
}
|
||||
});
|
||||
|
||||
const articles = await articlesData.json();
|
||||
const articles: (Article & { docs_category: DocsCategory | null })[] = await articlesData.json();
|
||||
|
||||
return {
|
||||
totalArticleCount,
|
||||
@@ -76,8 +77,8 @@ export const actions: Actions = {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
website_id: params.websiteId,
|
||||
title: data.get("title")
|
||||
})
|
||||
title: data.get("title") as string
|
||||
} satisfies ArticleInput)
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Actions, PageServerLoad } from "./$types";
|
||||
import { API_BASE_PREFIX } from "$lib/server/utils";
|
||||
import type { Article, DocsCategory } from "$lib/db-schema";
|
||||
|
||||
export const load: PageServerLoad = async ({ parent, params, cookies, fetch }) => {
|
||||
const articleData = await fetch(`${API_BASE_PREFIX}/article?id=eq.${params.articleId}`, {
|
||||
@@ -22,8 +23,8 @@ export const load: PageServerLoad = async ({ parent, params, cookies, fetch }) =
|
||||
}
|
||||
);
|
||||
|
||||
const article = await articleData.json();
|
||||
const categories = await categoryData.json();
|
||||
const article: Article = await articleData.json();
|
||||
const categories: DocsCategory[] = await categoryData.json();
|
||||
const { website } = await parent();
|
||||
|
||||
return { website, article, categories, API_BASE_PREFIX };
|
||||
|
||||
Reference in New Issue
Block a user