diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..ab78a95 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +# Package Managers +package-lock.json +pnpm-lock.yaml +yarn.lock diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..89e142b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,18 @@ +{ + "useTabs": true, + "singleQuote": true, + "trailingComma": "none", + "printWidth": 100, + "plugins": ["prettier-plugin-svelte"], + "overrides": [ + { + "files": "*.svelte", + "options": { + "parser": "svelte", + "svelteStrictMode": true, + "svelteBracketNewLine": false, + "svelteIndentScriptAndStyle": true + } + } + ] +} diff --git a/bun.lockb b/bun.lockb index 77fb198..0d524cb 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index a43320e..eb6ecdd 100644 --- a/package.json +++ b/package.json @@ -1,34 +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" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/kit": "^2.0.0", - "@sveltejs/vite-plugin-svelte": "^3.0.0", - "autoprefixer": "^10.4.20", - "daisyui": "^4.12.10", - "postcss": "^8.4.41", - "svelte": "^5.0.0-next.1", - "svelte-check": "^3.6.0", - "tailwindcss": "^3.4.10", - "typescript": "^5.0.0", - "vite": "^5.0.3" - }, - "type": "module", - "trustedDependencies": [ - "svelte-preprocess" - ], - "dependencies": { - "@olli/kvdex": "npm:@jsr/olli__kvdex", - "@ts-rex/argon2": "npm:@jsr/ts-rex__argon2", - "lucia": "^3.2.0" - } + "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/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/src/app.pcss b/src/app.pcss new file mode 100644 index 0000000..bd6213e --- /dev/null +++ b/src/app.pcss @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/src/lib/Tab.svelte b/src/lib/Tab.svelte new file mode 100644 index 0000000..986f79b --- /dev/null +++ b/src/lib/Tab.svelte @@ -0,0 +1,21 @@ + + +
+ {#each Object.entries(tabs) as [tabID]} + + + + tab = tabID} class:tab-active={tabID == tab}>{@render tabs[tabID]()} + {/each} +
\ No newline at end of file diff --git a/src/lib/apiclient.ts b/src/lib/apiclient.ts new file mode 100644 index 0000000..c596f7a --- /dev/null +++ b/src/lib/apiclient.ts @@ -0,0 +1,10 @@ +import { type api } from "./hono" +import { hc } from "hono/client" +export const client = hc('/api', { + async fetch(input: RequestInfo | URL, init?: RequestInit): Promise { + return await fetch(input, { + ...init, + credentials: 'include', + }) + } +}) \ No newline at end of file diff --git a/src/lib/db.ts b/src/lib/db.ts index e69de29..0e8df9a 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -0,0 +1,2 @@ +import { } from "@olli/kvdex" +import { } from "@deno/kv" \ No newline at end of file diff --git a/src/lib/hono.ts b/src/lib/hono.ts index e69de29..87a3dc0 100644 --- a/src/lib/hono.ts +++ b/src/lib/hono.ts @@ -0,0 +1,6 @@ +import { Hono } from "hono" + +const api = new Hono() +export type api = typeof api + +export const hono = new Hono().route('/api', api) \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte new file mode 100644 index 0000000..1af3ad6 --- /dev/null +++ b/src/routes/+layout.svelte @@ -0,0 +1,6 @@ + + +{@render children()} \ No newline at end of file diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 5982b0a..f0b453d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,2 +1 @@ -

Welcome to SvelteKit

-

Visit kit.svelte.dev to read the documentation

+ \ No newline at end of file diff --git a/src/routes/api/[...path]/+server.ts b/src/routes/api/[...path]/+server.ts new file mode 100644 index 0000000..3efd37b --- /dev/null +++ b/src/routes/api/[...path]/+server.ts @@ -0,0 +1,5 @@ +import { hono } from '$lib/hono.js'; + +export async function fallback({ request }) { + return hono.fetch(request) +} \ No newline at end of file diff --git a/src/routes/auth/+page.server.ts b/src/routes/auth/+page.server.ts new file mode 100644 index 0000000..caef26f --- /dev/null +++ b/src/routes/auth/+page.server.ts @@ -0,0 +1,33 @@ +import { fail, message, superValidate } from 'sveltekit-superforms'; +import { zod } from 'sveltekit-superforms/adapters'; +import { z } from 'zod'; + +const schema = z.object({ + username: z.string().min(4, "must be atleast 4 characters").max(32, "must be less than 32 characters").regex(/^[a-z0-9_\-]{4,32}$/i, `must be alphanumeric, with the exception of "_" and "-"`), + password: z.string().min(8, "must be atleast 8 characters") +}); + +export async function load() { + const form = await superValidate(zod(schema)); + return { form }; +}; + +export const actions = { + login: async ({ request }) => { + const form = await superValidate(request, zod(schema)); + + if (!form.valid) return fail(400, { form }); + + // TODO: Login user + return message(form, 'Login form submitted'); + }, + signup: async ({ request }) => { + const form = await superValidate(request, zod(schema)); + + if (!form.valid) return fail(400, { form }); + + // TODO: Login user + return message(form, 'Signup form submitted'); + + } +} \ No newline at end of file diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte new file mode 100644 index 0000000..5f61b72 --- /dev/null +++ b/src/routes/auth/+page.svelte @@ -0,0 +1,71 @@ + + +
+
+
+ + + + +
+ + +
+ {#if $message}{$message}{/if} +
+
+
+ + diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..08be3d2 --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,11 @@ +import daisyui from "daisyui" + +/** @type {import('tailwindcss').Config} */ +export default { + content: ['./src/**/*.{html,js,svelte,ts}'], + theme: { + extend: {}, + }, + plugins: [daisyui], +} +