diff --git a/.prettierrc b/.prettierrc index 2de21d7..7e9a1e9 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,8 +3,16 @@ "singleQuote": true, "semi": false, "trailingComma": "all", - "printWidth": 80, + "printWidth": 70, "bracketSameLine": true, - "plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"], - "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] + "plugins": [ + "prettier-plugin-svelte", + "prettier-plugin-tailwindcss" + ], + "overrides": [ + { + "files": "*.svelte", + "options": { "parser": "svelte" } + } + ] } diff --git a/src/app.html b/src/app.html index 77a5ff5..d9e6dd7 100644 --- a/src/app.html +++ b/src/app.html @@ -3,7 +3,9 @@ - + %sveltekit.head% diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 9797728..f7539a2 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -6,7 +6,12 @@ export const handle: Handle = async ({ event, resolve }) => { const pathname = event.url.pathname - const allowedPath = ['/login', '/signup', '/api/login', '/api/signup'] + const allowedPath = [ + '/login', + '/signup', + '/api/login', + '/api/signup', + ] if (pathname === '/login' || pathname === 'signup') { if (event.locals.user) { diff --git a/src/lib/components/sidebar.svelte b/src/lib/components/sidebar.svelte index 51d8e60..b8f9be0 100644 --- a/src/lib/components/sidebar.svelte +++ b/src/lib/components/sidebar.svelte @@ -1,7 +1,7 @@ -
+
- - + +
@@ -67,7 +74,8 @@ - Are you absolutely sure? + Are you absolutely sure? You are about to log out of this account. @@ -75,7 +83,10 @@ Cancel - +
diff --git a/src/routes/(auth)/login/+page.server.ts b/src/routes/(auth)/login/+page.server.ts index c1d46c7..2c80f63 100644 --- a/src/routes/(auth)/login/+page.server.ts +++ b/src/routes/(auth)/login/+page.server.ts @@ -3,7 +3,10 @@ import { fail } from '@sveltejs/kit' import { superValidate } from 'sveltekit-superforms/server' import { formSchema } from './schema' import { db } from '$lib/db' -import { session as sessionSchema, user as userSchema } from '$lib/db/schema' +import { + session as sessionSchema, + user as userSchema, +} from '$lib/db/schema' import { eq } from 'drizzle-orm' import { nanoid } from 'nanoid' import * as argon2 from 'argon2' @@ -33,7 +36,8 @@ export const actions: Actions = { const user = users[0] const matchPassword = // user && (await Bun.password.verify(form.data.password, user.password)) - user && (await argon2.verify(user.password, form.data.password)) + user && + (await argon2.verify(user.password, form.data.password)) if (user && matchPassword) { const token = nanoid(32) diff --git a/src/routes/(auth)/login/+page.svelte b/src/routes/(auth)/login/+page.svelte index 63eb723..535c1e9 100644 --- a/src/routes/(auth)/login/+page.svelte +++ b/src/routes/(auth)/login/+page.svelte @@ -8,7 +8,9 @@ export let data: PageData const guestLogin = async () => { - const response = await fetch('/api/login', { method: 'post' }) + const response = await fetch('/api/login', { + method: 'post', + }) const data = await response.json() if (data.success) { diff --git a/src/routes/(auth)/signup/+page.server.ts b/src/routes/(auth)/signup/+page.server.ts index 0713854..2567338 100644 --- a/src/routes/(auth)/signup/+page.server.ts +++ b/src/routes/(auth)/signup/+page.server.ts @@ -41,9 +41,10 @@ export const actions: Actions = { if (!user) { // const hashedPassword = await Bun.password.hash(form.data.password) const hashedPassword = await argon2.hash(form.data.password) - await db - .insert(userSchema) - .values({ email: form.data.email, password: hashedPassword }) + await db.insert(userSchema).values({ + email: form.data.email, + password: hashedPassword, + }) const token = nanoid(32) event.cookies.set('token', token, { httpOnly: true, diff --git a/src/routes/(auth)/signup/+page.svelte b/src/routes/(auth)/signup/+page.svelte index 9306155..ecfe027 100644 --- a/src/routes/(auth)/signup/+page.svelte +++ b/src/routes/(auth)/signup/+page.svelte @@ -22,7 +22,9 @@
-

Create an account

+

+ Create an account +

Enter your email below to create your account

diff --git a/src/routes/api/login/+server.ts b/src/routes/api/login/+server.ts index bd6874b..fc3e6b6 100644 --- a/src/routes/api/login/+server.ts +++ b/src/routes/api/login/+server.ts @@ -1,5 +1,8 @@ import type { RequestHandler } from './$types' -import { user as userSchema, session as sessionSchema } from '$lib/db/schema' +import { + user as userSchema, + session as sessionSchema, +} from '$lib/db/schema' import { db } from '$lib/db' import { nanoid } from 'nanoid' import { eq } from 'drizzle-orm' @@ -26,7 +29,9 @@ export const POST: RequestHandler = async (event) => { const expiresAt = new Date() expiresAt.setTime(expiresAt.getTime() + 4 * 60 * 60 * 1000) - await db.insert(sessionSchema).values({ userId: user.id, token, expiresAt }) + await db + .insert(sessionSchema) + .values({ userId: user.id, token, expiresAt }) event.cookies.set('token', token, { httpOnly: true, diff --git a/src/routes/api/logout/+server.ts b/src/routes/api/logout/+server.ts index 14c70bc..b05a59e 100644 --- a/src/routes/api/logout/+server.ts +++ b/src/routes/api/logout/+server.ts @@ -9,7 +9,10 @@ export const POST: RequestHandler = async (event) => { const token = event.cookies.get('token') if (!token) { return new Response( - JSON.stringify({ success: false, message: 'Invalid User' }), + JSON.stringify({ + success: false, + message: 'Invalid User', + }), ) } logoutUser(token) diff --git a/tailwind.config.js b/tailwind.config.js index 49e03bd..bd126c4 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -22,15 +22,18 @@ const config = { foreground: 'hsl(var(--foreground) / )', primary: { DEFAULT: 'hsl(var(--primary) / )', - foreground: 'hsl(var(--primary-foreground) / )', + foreground: + 'hsl(var(--primary-foreground) / )', }, secondary: { DEFAULT: 'hsl(var(--secondary) / )', - foreground: 'hsl(var(--secondary-foreground) / )', + foreground: + 'hsl(var(--secondary-foreground) / )', }, destructive: { DEFAULT: 'var(--destructive)', - foreground: 'hsl(var(--destructive-foreground) / )', + foreground: + 'hsl(var(--destructive-foreground) / )', }, muted: { DEFAULT: 'hsl(var(--muted) / )', @@ -42,7 +45,8 @@ const config = { }, popover: { DEFAULT: 'hsl(var(--popover) / )', - foreground: 'hsl(var(--popover-foreground) / )', + foreground: + 'hsl(var(--popover-foreground) / )', }, card: { DEFAULT: 'hsl(var(--card) / )',