update prettierrc

pull/3/head
TZGyn 2 years ago
parent 9fcba543cb
commit a768366513
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -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" }
}
]
}

@ -3,7 +3,9 @@
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="viewport"
content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">

@ -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) {

@ -1,7 +1,7 @@
<script lang="ts">
import { Separator } from '$lib/components/ui/separator'
import ThemeToggle from './theme-toggle.svelte'
import { Button, buttonVariants } from '$lib/components/ui/button'
import { Button } from '$lib/components/ui/button'
import * as Avatar from '$lib/components/ui/avatar'
import * as DropdownMenu from '$lib/components/ui/dropdown-menu'
import * as AlertDialog from '$lib/components/ui/alert-dialog'
@ -22,18 +22,25 @@
}
</script>
<div class="flex h-full min-w-[350px] flex-col justify-between border-r p-4">
<div
class="flex h-full min-w-[350px] flex-col justify-between border-r p-4">
<div>
<div class="flex items-center justify-between pb-16">
<div class="text-xl font-bold"><a href="/">Shortener</a></div>
<div class="text-xl font-bold">
<a href="/">Shortener</a>
</div>
<ThemeToggle />
</div>
<div class="flex flex-col gap-4">
<Button variant="ghost" href="/links" class="justify-start text-base"
>Links</Button>
<Button variant="ghost" href="/projects" class="justify-start text-base "
>Projects</Button>
<Button
variant="ghost"
href="/links"
class="justify-start text-base">Links</Button>
<Button
variant="ghost"
href="/projects"
class="justify-start text-base ">Projects</Button>
</div>
</div>
@ -67,7 +74,8 @@
<AlertDialog.Root bind:open={dialogOpen}>
<AlertDialog.Content>
<AlertDialog.Header>
<AlertDialog.Title>Are you absolutely sure?</AlertDialog.Title>
<AlertDialog.Title
>Are you absolutely sure?</AlertDialog.Title>
<AlertDialog.Description>
You are about to log out of this account.
</AlertDialog.Description>
@ -75,7 +83,10 @@
<AlertDialog.Footer>
<AlertDialog.Cancel disabled={isLoading}
>Cancel</AlertDialog.Cancel>
<Button on:click={logout} class="flex gap-2" disabled={isLoading}>
<Button
on:click={logout}
class="flex gap-2"
disabled={isLoading}>
{#if isLoading}
<Loader2 class="animate-spin" />
{/if}

@ -19,7 +19,9 @@
<DropdownMenu.Content>
<DropdownMenu.Item on:click={() => setMode('light')}
>Light</DropdownMenu.Item>
<DropdownMenu.Item on:click={() => setMode('dark')}>Dark</DropdownMenu.Item>
<DropdownMenu.Item on:click={() => resetMode()}>System</DropdownMenu.Item>
<DropdownMenu.Item on:click={() => setMode('dark')}
>Dark</DropdownMenu.Item>
<DropdownMenu.Item on:click={() => resetMode()}
>System</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>

@ -11,7 +11,11 @@
</script>
<AlertDialogPrimitive.Cancel
class={cn(buttonVariants({ variant: 'outline' }), 'mt-2 sm:mt-0', className)}
class={cn(
buttonVariants({ variant: 'outline' }),
'mt-2 sm:mt-0',
className,
)}
{...$$restProps}
on:click
on:keydown

@ -9,7 +9,10 @@
</script>
<div
class={cn('flex flex-col space-y-2 text-center sm:text-left', className)}
class={cn(
'flex flex-col space-y-2 text-center sm:text-left',
className,
)}
{...$$restProps}>
<slot />
</div>

@ -16,5 +16,8 @@
<AlertDialogPrimitive.Overlay
{transition}
{transitionConfig}
class={cn('fixed inset-0 z-50 bg-background/80 backdrop-blur-sm ', className)}
class={cn(
'fixed inset-0 z-50 bg-background/80 backdrop-blur-sm ',
className,
)}
{...$$restProps} />

@ -12,7 +12,8 @@ const buttonVariants = tv({
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline:
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
},

@ -8,6 +8,8 @@
export { className as class }
</script>
<p class={cn('text-sm text-muted-foreground', className)} {...$$restProps}>
<p
class={cn('text-sm text-muted-foreground', className)}
{...$$restProps}>
<slot />
</p>

@ -8,6 +8,8 @@
export { className as class }
</script>
<div class={cn('flex items-center p-6 pt-0', className)} {...$$restProps}>
<div
class={cn('flex items-center p-6 pt-0', className)}
{...$$restProps}>
<slot />
</div>

@ -8,6 +8,8 @@
export { className as class }
</script>
<div class={cn('flex flex-col space-y-1.5 p-6', className)} {...$$restProps}>
<div
class={cn('flex flex-col space-y-1.5 p-6', className)}
{...$$restProps}>
<slot />
</div>

@ -14,7 +14,10 @@
<svelte:element
this={tag}
class={cn('text-lg font-semibold leading-none tracking-tight', className)}
class={cn(
'text-lg font-semibold leading-none tracking-tight',
className,
)}
{...$$restProps}>
<slot />
</svelte:element>

@ -20,7 +20,9 @@
{...$$restProps}
on:click>
<CheckboxPrimitive.Indicator
class={cn('flex h-4 w-4 items-center justify-center text-current')}
class={cn(
'flex h-4 w-4 items-center justify-center text-current',
)}
let:isChecked
let:isIndeterminate>
{#if isChecked}

@ -9,7 +9,10 @@
</script>
<div
class={cn('flex flex-col space-y-1.5 text-center sm:text-left', className)}
class={cn(
'flex flex-col space-y-1.5 text-center sm:text-left',
className,
)}
{...$$restProps}>
<slot />
</div>

@ -16,5 +16,8 @@
<DialogPrimitive.Overlay
{transition}
{transitionConfig}
class={cn('fixed inset-0 z-50 bg-background/80 backdrop-blur-sm', className)}
class={cn(
'fixed inset-0 z-50 bg-background/80 backdrop-blur-sm',
className,
)}
{...$$restProps} />

@ -9,7 +9,10 @@
</script>
<DialogPrimitive.Title
class={cn('text-lg font-semibold leading-none tracking-tight', className)}
class={cn(
'text-lg font-semibold leading-none tracking-tight',
className,
)}
{...$$restProps}>
<slot />
</DialogPrimitive.Title>

@ -25,7 +25,8 @@
on:pointerdown
on:pointerleave
on:pointermove>
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<span
class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<DropdownMenuPrimitive.CheckboxIndicator>
<Check class="h-4 w-4" />
</DropdownMenuPrimitive.CheckboxIndicator>

@ -12,7 +12,11 @@
</script>
<DropdownMenuPrimitive.Label
class={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
class={cn(
'px-2 py-1.5 text-sm font-semibold',
inset && 'pl-8',
className,
)}
{...$$restProps}>
<slot />
</DropdownMenuPrimitive.Label>

@ -25,7 +25,8 @@
on:pointerdown
on:pointerleave
on:pointermove>
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<span
class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<DropdownMenuPrimitive.RadioIndicator>
<Circle class="h-2 w-2 fill-current" />
</DropdownMenuPrimitive.RadioIndicator>

@ -2,7 +2,10 @@
import { getFormField } from 'formsnap'
import type { HTMLTextareaAttributes } from 'svelte/elements'
import type { TextareaGetFormField } from '.'
import { Textarea, type TextareaEvents } from '$lib/components/ui/textarea'
import {
Textarea,
type TextareaEvents,
} from '$lib/components/ui/textarea'
type $$Props = HTMLTextareaAttributes
type $$Events = TextareaEvents

@ -6,7 +6,8 @@
type $$Props = SelectPrimitive.ContentProps
type $$Events = SelectPrimitive.ContentEvents
export let inTransition: $$Props['inTransition'] = flyAndScale
export let inTransitionConfig: $$Props['inTransitionConfig'] = undefined
export let inTransitionConfig: $$Props['inTransitionConfig'] =
undefined
export let outTransition: $$Props['outTransition'] = scale
export let outTransitionConfig: $$Props['outTransitionConfig'] = {
start: 0.95,

@ -28,7 +28,8 @@
on:focusout
on:pointerleave
on:pointermove>
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<span
class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<SelectPrimitive.ItemIndicator>
<Check class="h-4 w-4" />
</SelectPrimitive.ItemIndicator>

@ -13,7 +13,9 @@
<SeparatorPrimitive.Root
class={cn(
'shrink-0 bg-border',
orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]',
orientation === 'horizontal'
? 'h-[1px] w-full'
: 'h-full w-[1px]',
className,
)}
{orientation}

@ -13,7 +13,9 @@ export const shortener = pgTable('shortener', {
id: serial('id').primaryKey().notNull(),
link: varchar('link', { length: 255 }).notNull(),
code: varchar('code', { length: 255 }).notNull(),
createdAt: timestamp('created_at', { mode: 'string' }).defaultNow().notNull(),
createdAt: timestamp('created_at', { mode: 'string' })
.defaultNow()
.notNull(),
userId: integer('user_id').notNull(),
})
@ -30,21 +32,29 @@ export const user = pgTable('user', {
email: varchar('email', { length: 255 }).notNull().unique(),
username: varchar('username', { length: 255 }),
password: varchar('password', { length: 255 }).notNull(),
createdAt: timestamp('created_at', { mode: 'string' }).defaultNow().notNull(),
createdAt: timestamp('created_at', { mode: 'string' })
.defaultNow()
.notNull(),
})
export const visitor = pgTable('visitor', {
id: serial('id').primaryKey().notNull(),
shortenerId: integer('shortener_id').notNull(),
createdAt: timestamp('created_at', { mode: 'string' }).defaultNow().notNull(),
countryCode: varchar('country_code', { length: 255 }).notNull(),
createdAt: timestamp('created_at', { mode: 'string' })
.defaultNow()
.notNull(),
countryCode: varchar('country_code', {
length: 255,
}).notNull(),
country: varchar('country', { length: 255 }).notNull(),
})
export const session = pgTable('session', {
token: varchar('token', { length: 255 }).notNull(),
userId: integer('user_id').notNull(),
expiresAt: timestamp('expires', { mode: 'date' }).notNull(),
expiresAt: timestamp('expires', {
mode: 'date',
}).notNull(),
})
export const sessionRelations = relations(session, ({ one }) => ({

@ -9,7 +9,10 @@ export const getUserFromSessionToken = async (token: string) => {
.select()
.from(sessionSchema)
.where(
and(eq(sessionSchema.token, token), gt(sessionSchema.expiresAt, now)),
and(
eq(sessionSchema.token, token),
gt(sessionSchema.expiresAt, now),
),
)
const session = sessions[0]

@ -16,7 +16,12 @@ type FlyAndScaleParams = {
export const flyAndScale = (
node: Element,
params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 },
params: FlyAndScaleParams = {
y: -8,
x: 0,
start: 0.95,
duration: 150,
},
): TransitionConfig => {
const style = getComputedStyle(node)
const transform = style.transform === 'none' ? '' : style.transform
@ -50,7 +55,11 @@ export const flyAndScale = (
css: (t) => {
const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0])
const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0])
const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1])
const scale = scaleConversion(
t,
[0, 1],
[params.start ?? 0.95, 1],
)
return styleToString({
transform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,

@ -1,5 +1,7 @@
import type { LayoutServerLoad } from './$types'
export const load = (async () => {
return { shortener_url: process.env.SHORTENER_URL ?? 's.tzgyn.com' }
return {
shortener_url: process.env.SHORTENER_URL ?? 's.tzgyn.com',
}
}) satisfies LayoutServerLoad

@ -1,4 +1,5 @@
<h1 class="text-xl">Welcome to SvelteKit</h1>
<p>
Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation
Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the
documentation
</p>

@ -9,6 +9,7 @@
<div class="text-4xl font-bold">404</div>
<div class="text-4xl font-bold">Page Not Found</div>
</div>
<Button on:click={() => goto('/')} class="w-fit">Return Home</Button>
<Button on:click={() => goto('/')} class="w-fit"
>Return Home</Button>
</div>
</div>

@ -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)

@ -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) {

@ -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,

@ -22,7 +22,9 @@
<div
class="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]">
<div class="flex flex-col space-y-2 text-center">
<h1 class="text-2xl font-semibold tracking-tight">Create an account</h1>
<h1 class="text-2xl font-semibold tracking-tight">
Create an account
</h1>
<p class="text-sm text-muted-foreground">
Enter your email below to create your account
</p>

@ -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,

@ -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)

@ -22,15 +22,18 @@ const config = {
foreground: 'hsl(var(--foreground) / <alpha-value>)',
primary: {
DEFAULT: 'hsl(var(--primary) / <alpha-value>)',
foreground: 'hsl(var(--primary-foreground) / <alpha-value>)',
foreground:
'hsl(var(--primary-foreground) / <alpha-value>)',
},
secondary: {
DEFAULT: 'hsl(var(--secondary) / <alpha-value>)',
foreground: 'hsl(var(--secondary-foreground) / <alpha-value>)',
foreground:
'hsl(var(--secondary-foreground) / <alpha-value>)',
},
destructive: {
DEFAULT: 'var(--destructive)',
foreground: 'hsl(var(--destructive-foreground) / <alpha-value>)',
foreground:
'hsl(var(--destructive-foreground) / <alpha-value>)',
},
muted: {
DEFAULT: 'hsl(var(--muted) / <alpha-value>)',
@ -42,7 +45,8 @@ const config = {
},
popover: {
DEFAULT: 'hsl(var(--popover) / <alpha-value>)',
foreground: 'hsl(var(--popover-foreground) / <alpha-value>)',
foreground:
'hsl(var(--popover-foreground) / <alpha-value>)',
},
card: {
DEFAULT: 'hsl(var(--card) / <alpha-value>)',

Loading…
Cancel
Save