([]);
+
+ async function getAllArticles() {
+ const result = await fetch(
+ "/api/articles/getAllArticles",
+ {
+ method: "GET",
+ headers: { "Accept": "application/json" }
+ }
+ );
+
+ const json = await result.json();
+ const data = ArticleListSchema.parse(json);
+ console.log(data);
+ setArticles(data);
+
+ };
+
return (
-
- List of articles to be populated and searchable
-
+
+
+ List of articles to be populated and searchable
+
+
+
+ {articles.map((article) => (
))}
+
+
);
};
diff --git a/frontend/src/types/Article.ts b/frontend/src/types/Article.ts
new file mode 100644
index 0000000..925247a
--- /dev/null
+++ b/frontend/src/types/Article.ts
@@ -0,0 +1,16 @@
+import { z } from 'zod';
+
+export const ArticleSchema = z.object({
+ id: z.string(),
+ name: z.string(),
+ article_status: z.enum(["draft", "published", "archived"]),
+ author_id: z.string(),
+ slug: z.string(),
+ summary: z.string(),
+ date_created: z.string(),
+ last_edit: z.string(),
+ date_published: z.string().nullable(),
+});
+
+export const ArticleListSchema = z.array(ArticleSchema);
+export type Article = z.infer;
diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json
index 1ffef60..cd68bb2 100644
--- a/frontend/tsconfig.json
+++ b/frontend/tsconfig.json
@@ -1,7 +1,14 @@
{
"files": [],
"references": [
- { "path": "./tsconfig.app.json" },
- { "path": "./tsconfig.node.json" }
- ]
+ {
+ "path": "./tsconfig.app.json"
+ },
+ {
+ "path": "./tsconfig.node.json"
+ }
+ ],
+ "compilerOptions": {
+ "strict": true
+ }
}