diff --git a/deno.json b/deno.json
index 0ece85826..ed219b44a 100644
--- a/deno.json
+++ b/deno.json
@@ -18,7 +18,7 @@
},
"imports": {
"@/": "./",
- "$fresh/": "https://deno.land/x/fresh@1.3.0/",
+ "$fresh/": "https://raw.githubusercontent.com/deer/fresh/feat_plugin_islands/",
"$gfm": "https://deno.land/x/gfm@0.2.4/mod.ts",
"preact": "https://esm.sh/preact@10.15.1",
"preact/": "https://esm.sh/preact@10.15.1/",
@@ -32,6 +32,8 @@
"feed": "https://esm.sh/feed@4.2.2",
"kv_oauth": "https://deno.land/x/deno_kv_oauth@v0.2.5/mod.ts",
"@twind/core": "https://esm.sh/@twind/core@1.1.3",
+ "pentagon/": "https://deno.land/x/pentagon@v0.1.2/",
+ "z": "https://deno.land/x/zod@v3.21.4/mod.ts",
"fresh_charts/": "https://deno.land/x/fresh_charts@0.3.1/"
},
"exclude": [
diff --git a/main.ts b/main.ts
index 9d8be797b..7a4ae24ab 100644
--- a/main.ts
+++ b/main.ts
@@ -6,12 +6,17 @@
///
///
+import * as path from "std/path/mod.ts";
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
import twindPlugin from "$fresh/plugins/twindv1.ts";
import twindConfig from "./twind.config.ts";
+import {
+ kvAdminPlugin,
+} from "https://raw.githubusercontent.com/deer/fresh_kv_admin/main/mod.ts";
+
/**
* @todo Remove at v1. This is a quick way to reset Deno KV, as database changes are likely to occur and require reset.
*/
@@ -29,4 +34,11 @@ if (Deno.env.get("MIGRATE_DENO_KEY") === "1") {
await migrateKv();
}
-await start(manifest, { plugins: [twindPlugin(twindConfig)] });
+await start(manifest, {
+ plugins: [
+ twindPlugin(twindConfig),
+ await kvAdminPlugin({
+ modelPath: path.join(path.dirname(import.meta.url), "utils/types.ts"),
+ }),
+ ],
+});
diff --git a/utils/types.ts b/utils/types.ts
new file mode 100644
index 000000000..f6dab9809
--- /dev/null
+++ b/utils/types.ts
@@ -0,0 +1,28 @@
+// import { Item } from "./db.ts";
+import { TableDefinition } from "pentagon/src/types.ts";
+import { z } from "z";
+
+export interface Item {
+ userId: string;
+ title: string;
+ url: string;
+ // The below properties can be automatically generated upon item creation
+ id: string;
+ createdAt: Date;
+ score: number;
+}
+
+const item = z.object({
+ id: z.string().uuid().describe("primary"),
+ createdAt: z.coerce.date(),
+ score: z.coerce.number(),
+ url: z.string(),
+ title: z.string(),
+ userId: z.string().uuid(),
+});
+
+export const schema: Record = {
+ items: {
+ schema: item,
+ },
+};