From 8697c2fe767af28d6bbb572acf3ee5ce1689c482 Mon Sep 17 00:00:00 2001 From: Chad Freeman Date: Sat, 17 Aug 2024 00:51:55 -0400 Subject: [PATCH] initalize db --- package.json | 76 ++++++++++++++++++------------------ src/lib/db.ts | 31 ++++++++++++++- src/routes/auth/+page.svelte | 64 ++++++++++++++++++++++++++---- 3 files changed, 123 insertions(+), 48 deletions(-) diff --git a/package.json b/package.json index eb6ecdd..e658ed5 100644 --- a/package.json +++ b/package.json @@ -1,40 +1,40 @@ { - "name": "talkomatic", - "version": "0.0.1", - "private": true, - "scripts": { - "dev": "vite dev", - "build": "vite build", - "preview": "vite preview", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "format": "prettier --write .", - "lint": "prettier --check ." - }, - "devDependencies": { - "@deno/kv": "^0.8.1", - "@olli/kvdex": "npm:@jsr/olli__kvdex", - "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/kit": "^2.0.0", - "@sveltejs/vite-plugin-svelte": "^3.0.0", - "@ts-rex/argon2": "npm:@jsr/ts-rex__argon2", - "autoprefixer": "^10.4.20", - "daisyui": "^4.12.10", - "hono": "^4.5.5", - "lucia": "^3.2.0", - "postcss": "^8.4.41", - "prettier": "^3.3.2", - "prettier-plugin-svelte": "^3.2.5", - "svelte": "^5.0.0-next.1", - "svelte-check": "^3.6.0", - "sveltekit-superforms": "^2.17.0", - "tailwindcss": "^3.4.10", - "typescript": "^5.0.0", - "vite": "^5.0.3", - "zod": "^3.23.8" - }, - "type": "module", - "trustedDependencies": [ - "svelte-preprocess" - ] + "name": "talkomatic", + "version": "0.0.1", + "private": true, + "scripts": { + "dev": "vite dev", + "build": "vite build", + "preview": "vite preview", + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "format": "prettier --write .", + "lint": "prettier --check ." + }, + "devDependencies": { + "@deno/kv": "^0.8.1", + "@olli/kvdex": "npm:@jsr/olli__kvdex", + "@sveltejs/adapter-auto": "^3.0.0", + "@sveltejs/kit": "^2.0.0", + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "@ts-rex/argon2": "npm:@jsr/ts-rex__argon2", + "autoprefixer": "^10.4.20", + "daisyui": "^4.12.10", + "hono": "^4.5.5", + "lucia": "^3.2.0", + "postcss": "^8.4.41", + "prettier": "^3.3.2", + "prettier-plugin-svelte": "^3.2.5", + "svelte": "^5.0.0-next.1", + "svelte-check": "^3.6.0", + "sveltekit-superforms": "^2.17.0", + "tailwindcss": "^3.4.10", + "typescript": "^5.0.0", + "vite": "^5.0.3", + "zod": "^3.23.8" + }, + "type": "module", + "trustedDependencies": [ + "svelte-preprocess" + ] } diff --git a/src/lib/db.ts b/src/lib/db.ts index 0e8df9a..7e03c5c 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -1,2 +1,29 @@ -import { } from "@olli/kvdex" -import { } from "@deno/kv" \ No newline at end of file +import { kvdex as gate_keeping_the_database, collection, model } from "@olli/kvdex" +import { openKv } from "@deno/kv" +import { z } from "zod" + +const user = z.object({ + username: z.string(), + password: z.string(), + id: z.string(), +}) + +const session = z.object({ + expiresAt: z.date(), + userId: z.string(), +}) + +export const gate_keeping_this_too = await openKv() +export const db = gate_keeping_the_database(gate_keeping_this_too, { + user: collection(user), + session: collection(session, { + indices: { + userId: 'secondary' + } + }), + pfp: collection(model()), + chat: { + boxes: collection(model<{ userID: string, text: string }>()), + users: collection(user.pick({ username: true, id: true })) + } +}) \ No newline at end of file diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index 5f61b72..43509dd 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -1,13 +1,61 @@
-
-
+
+

sign up/in

+ + or + - +