From e01163461fbd21bc49406095a6775d564575a131 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Tue, 17 Dec 2024 14:52:50 -0500 Subject: [PATCH 01/28] add dependency --- docs/DAISY.md | 3 +++ package.json | 1 + tailwind.config.ts | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 docs/DAISY.md diff --git a/docs/DAISY.md b/docs/DAISY.md new file mode 100644 index 0000000..47728b9 --- /dev/null +++ b/docs/DAISY.md @@ -0,0 +1,3 @@ +# Experienced Issues + +- https://github.com/saadeghi/daisyui/issues/811 \ No newline at end of file diff --git a/package.json b/package.json index 22de0de..a0b08e1 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "@sveltejs/vite-plugin-svelte": "^5.0.0", "@types/bun": "^1.1.14", "autoprefixer": "^10.4.20", + "daisyui": "^4.12.22", "eslint": "^9.7.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-svelte": "^2.36.0", diff --git a/tailwind.config.ts b/tailwind.config.ts index 575e6fd..065ea6d 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -1,4 +1,5 @@ import typography from '@tailwindcss/typography'; +import daisyui from 'daisyui'; import type { Config } from 'tailwindcss'; export default { @@ -21,5 +22,8 @@ export default { } }, - plugins: [typography] + plugins: [typography, daisyui], + daisyui: { + logs: false + } } satisfies Config; \ No newline at end of file -- 2.45.3 From a8b3d2992fe91a86af83111b4274323932dba861 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Tue, 17 Dec 2024 17:14:03 -0500 Subject: [PATCH 02/28] rename Input to TextInput and use daisy --- src/lib/components/Input.stories.svelte | 43 --------------------- src/lib/components/Input.svelte | 36 ----------------- src/lib/components/TextInput.stories.svelte | 13 +++++++ src/lib/components/TextInput.svelte | 27 +++++++++++++ src/routes/login/+page.svelte | 8 ++-- 5 files changed, 44 insertions(+), 83 deletions(-) delete mode 100644 src/lib/components/Input.stories.svelte delete mode 100644 src/lib/components/Input.svelte create mode 100644 src/lib/components/TextInput.stories.svelte create mode 100644 src/lib/components/TextInput.svelte diff --git a/src/lib/components/Input.stories.svelte b/src/lib/components/Input.stories.svelte deleted file mode 100644 index f3810b9..0000000 --- a/src/lib/components/Input.stories.svelte +++ /dev/null @@ -1,43 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/lib/components/Input.svelte b/src/lib/components/Input.svelte deleted file mode 100644 index 4b58ee1..0000000 --- a/src/lib/components/Input.svelte +++ /dev/null @@ -1,36 +0,0 @@ - - -
- {#if label} - -
- {/if} - -
- - \ No newline at end of file diff --git a/src/lib/components/TextInput.stories.svelte b/src/lib/components/TextInput.stories.svelte new file mode 100644 index 0000000..19a5afa --- /dev/null +++ b/src/lib/components/TextInput.stories.svelte @@ -0,0 +1,13 @@ + + + \ No newline at end of file diff --git a/src/lib/components/TextInput.svelte b/src/lib/components/TextInput.svelte new file mode 100644 index 0000000..e4041e7 --- /dev/null +++ b/src/lib/components/TextInput.svelte @@ -0,0 +1,27 @@ + + + + + \ No newline at end of file diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index 1eb8b77..98c37c2 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -1,6 +1,6 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/lib/components/Button.svelte b/src/lib/components/Button.svelte index 2c8737a..9859e56 100644 --- a/src/lib/components/Button.svelte +++ b/src/lib/components/Button.svelte @@ -1,51 +1,54 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/lib/types/daisy-colors.ts b/src/lib/types/daisy-colors.ts new file mode 100644 index 0000000..c5d5a56 --- /dev/null +++ b/src/lib/types/daisy-colors.ts @@ -0,0 +1,12 @@ +export type DaisyColor = + | 'default' + | 'neutral' + | 'primary' + | 'secondary' + | 'accent' + | 'ghost' + | 'link' + | 'info' + | 'success' + | 'warning' + | 'error'; \ No newline at end of file diff --git a/src/lib/types/daisy-sizes.ts b/src/lib/types/daisy-sizes.ts new file mode 100644 index 0000000..9cd1207 --- /dev/null +++ b/src/lib/types/daisy-sizes.ts @@ -0,0 +1 @@ +export type DaisySize = 'xs' | 'sm' | 'lg'; \ No newline at end of file diff --git a/src/lib/types/index.ts b/src/lib/types/index.ts new file mode 100644 index 0000000..93ffa73 --- /dev/null +++ b/src/lib/types/index.ts @@ -0,0 +1,2 @@ +export * from './daisy-colors'; +export * from './daisy-sizes'; \ No newline at end of file diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index 98c37c2..4ce03a1 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -24,13 +24,8 @@
-
-- 2.45.3 From e251f7ae8a3a962db6d3165fe0c8e247780b1054 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Wed, 18 Dec 2024 14:10:02 -0500 Subject: [PATCH 06/28] add flaticons --- .storybook/preview.css | 7 ++++--- package.json | 5 +++-- src/app.css | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.storybook/preview.css b/.storybook/preview.css index bd6213e..746f0f9 100644 --- a/.storybook/preview.css +++ b/.storybook/preview.css @@ -1,3 +1,4 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; \ No newline at end of file +@import 'tailwindcss/base'; +@import 'tailwindcss/components'; +@import 'tailwindcss/utilities'; +@import '@flaticon/flaticon-uicons/css/all/all'; \ No newline at end of file diff --git a/package.json b/package.json index e043642..15c7ea8 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "vitest": "^2.0.4" }, "dependencies": { - "@lucia-auth/adapter-prisma": "^4.0.1", + "@flaticon/flaticon-uicons": "^3.3.1", + "@lucia-auth/adapter-prisma": "^4.0.1", "@pothos/core": "^4.3.0", "@pothos/plugin-prisma": "^4.4.0", "@prisma/client": "6.0.1", @@ -70,4 +71,4 @@ "tailwind-merge": "^2.5.5", "zod": "^3.24.0" } -} +} \ No newline at end of file diff --git a/src/app.css b/src/app.css index af0ce51..0a388d3 100644 --- a/src/app.css +++ b/src/app.css @@ -1,6 +1,7 @@ @import 'tailwindcss/base'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities'; +@import '@flaticon/flaticon-uicons/css/all/all'; :root { @apply text-base-content; -- 2.45.3 From 8f4f81a17d7e7543502f685a3bf8b27af50cb09d Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Wed, 18 Dec 2024 14:56:49 -0500 Subject: [PATCH 07/28] text input to daisy --- src/lib/components/TextInput.stories.svelte | 37 ++++++++++++- src/lib/components/TextInput.svelte | 61 +++++++++++++++++---- src/routes/login/+page.svelte | 20 +++++-- 3 files changed, 101 insertions(+), 17 deletions(-) diff --git a/src/lib/components/TextInput.stories.svelte b/src/lib/components/TextInput.stories.svelte index 19a5afa..f207c1c 100644 --- a/src/lib/components/TextInput.stories.svelte +++ b/src/lib/components/TextInput.stories.svelte @@ -6,8 +6,41 @@ title: 'TextInput', component: TextInput, tags: ['autodocs'], - argTypes: {} + argTypes: { + color: { + control: 'select', + options: [ + 'primary', + 'secondary', + 'accent', + 'ghost', + 'link', + 'info', + 'success', + 'warning', + 'error' + ] + }, + bordered: { + control: 'boolean' + }, + size: { + control: 'select', + options: ['Default', 'xs', 'sm', 'lg'], + defaultValue: 'Default' + }, + type: { + control: 'select', + options: ['email', 'password', 'search', 'tel', 'text', 'url'] + } + } }); - \ No newline at end of file +{#snippet icon()} + +{/snippet} + + + + \ No newline at end of file diff --git a/src/lib/components/TextInput.svelte b/src/lib/components/TextInput.svelte index e4041e7..50bfd05 100644 --- a/src/lib/components/TextInput.svelte +++ b/src/lib/components/TextInput.svelte @@ -1,26 +1,67 @@ - \ No newline at end of file + diff --git a/src/lib/components/common/TextInput/index.ts b/src/lib/components/common/TextInput/index.ts index c2707e8..89470e9 100644 --- a/src/lib/components/common/TextInput/index.ts +++ b/src/lib/components/common/TextInput/index.ts @@ -1,3 +1,3 @@ import TextInput from './TextInput.svelte'; -export default TextInput; \ No newline at end of file +export default TextInput; diff --git a/src/lib/index.ts b/src/lib/index.ts index e5efcb2..aa2aa7e 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,2 +1,2 @@ // place files you want to import through the `$lib` alias in this folder. -export * from './components'; \ No newline at end of file +export * from './components'; diff --git a/src/lib/server/config/index.ts b/src/lib/server/config/index.ts index b7dcdbe..0239640 100644 --- a/src/lib/server/config/index.ts +++ b/src/lib/server/config/index.ts @@ -8,7 +8,7 @@ export interface Configuration { export const LoadConfig = (): Configuration => { const { success, data, error } = z .object({ - VITE_APP_VERSION: z.string().default('development') + VITE_APP_VERSION: z.string().default('development'), }) .safeParse(import.meta.env); @@ -17,8 +17,8 @@ export const LoadConfig = (): Configuration => { } return { - app_version: data!.VITE_APP_VERSION + app_version: data!.VITE_APP_VERSION, }; }; -export const Config = LoadConfig(); \ No newline at end of file +export const Config = LoadConfig(); diff --git a/src/lib/server/logger/index.ts b/src/lib/server/logger/index.ts index 38ed4aa..7dea51d 100644 --- a/src/lib/server/logger/index.ts +++ b/src/lib/server/logger/index.ts @@ -19,5 +19,5 @@ export const yogaLogger: YogaLogger = { error(...args) { // @ts-expect-error types dont match logger.error(...args); - } -}; \ No newline at end of file + }, +}; diff --git a/src/lib/server/lucia.ts b/src/lib/server/lucia.ts index ac99da9..be9c091 100644 --- a/src/lib/server/lucia.ts +++ b/src/lib/server/lucia.ts @@ -7,14 +7,14 @@ const adapter = new PrismaAdapter(prisma.session, prisma.user); export const auth = new Lucia(adapter, { sessionCookie: { attributes: { - secure: process.env.NODE_ENV === 'production' - } + secure: process.env.NODE_ENV === 'production', + }, }, getUserAttributes: (attributes) => { return { - email: attributes.email + email: attributes.email, }; - } + }, }); declare module 'lucia' { diff --git a/src/lib/server/pothos/builder.ts b/src/lib/server/pothos/builder.ts index 0b7fda4..15de43f 100644 --- a/src/lib/server/pothos/builder.ts +++ b/src/lib/server/pothos/builder.ts @@ -23,6 +23,6 @@ export const builder = new SchemaBuilder({ // use where clause from prismaRelatedConnection for totalCount (defaults to true) filterConnectionTotalCount: true, // warn when not using a query parameter correctly - onUnusedQuery: process.env.NODE_ENV === 'production' ? null : 'warn' - } -}); \ No newline at end of file + onUnusedQuery: process.env.NODE_ENV === 'production' ? null : 'warn', + }, +}); diff --git a/src/lib/server/pothos/index.ts b/src/lib/server/pothos/index.ts index 5d5aa13..e27a6e2 100644 --- a/src/lib/server/pothos/index.ts +++ b/src/lib/server/pothos/index.ts @@ -1 +1 @@ -export * from './schema'; \ No newline at end of file +export * from './schema'; diff --git a/src/lib/server/pothos/schema/Scalars/Date.ts b/src/lib/server/pothos/schema/Scalars/Date.ts index 6573f0a..7fe4322 100644 --- a/src/lib/server/pothos/schema/Scalars/Date.ts +++ b/src/lib/server/pothos/schema/Scalars/Date.ts @@ -10,5 +10,5 @@ export const DateScalar = builder.scalarType('Date', { throw new Error('Cyka blyat'); } return new Date(date); - } -}); \ No newline at end of file + }, +}); diff --git a/src/lib/server/pothos/schema/Scalars/index.ts b/src/lib/server/pothos/schema/Scalars/index.ts index 0751f41..337b487 100644 --- a/src/lib/server/pothos/schema/Scalars/index.ts +++ b/src/lib/server/pothos/schema/Scalars/index.ts @@ -5,4 +5,4 @@ export type Scalars = { Input: Date; Output: Date; }; -}; \ No newline at end of file +}; diff --git a/src/lib/server/pothos/schema/index.ts b/src/lib/server/pothos/schema/index.ts index acdab44..84e199f 100644 --- a/src/lib/server/pothos/schema/index.ts +++ b/src/lib/server/pothos/schema/index.ts @@ -5,7 +5,7 @@ builder.queryType({}); builder.queryField('version', (t) => t.string({ description: 'Application version', - resolve: (parent, args, context) => context.config.app_version + resolve: (parent, args, context) => context.config.app_version, }) ); @@ -15,4 +15,4 @@ import './Scalars'; import './posts'; import './users'; -export const Schema = builder.toSchema(); \ No newline at end of file +export const Schema = builder.toSchema(); diff --git a/src/lib/server/pothos/schema/posts.ts b/src/lib/server/pothos/schema/posts.ts index f616871..1885f06 100644 --- a/src/lib/server/pothos/schema/posts.ts +++ b/src/lib/server/pothos/schema/posts.ts @@ -9,39 +9,39 @@ export const Post = builder.prismaObject('Post', { published: t.exposeBoolean('published'), author: t.relation('author'), createdAt: t.expose('createdAt', { - type: 'Date' + type: 'Date', }), updatedAt: t.expose('updatedAt', { - type: 'Date' - }) - }) + type: 'Date', + }), + }), }); const CreatePost = builder.inputType('CreatePost', { fields: (t) => ({ title: t.string({ - required: true + required: true, }), content: t.string({ - required: true + required: true, }), published: t.boolean(), authorId: t.id({ - required: true - }) - }) + required: true, + }), + }), }); const UpdatePost = builder.inputType('UpdatePost', { fields: (t) => ({ id: t.id({ - required: true + required: true, }), title: t.string(), content: t.string(), published: t.boolean(), - authorId: t.id() - }) + authorId: t.id(), + }), }); builder.queryFields((t) => ({ @@ -49,19 +49,19 @@ builder.queryFields((t) => ({ type: [Post], resolve: async () => { return await prisma.post.findMany(); - } - }) + }, + }), })); builder.mutationFields((t) => ({ createPost: t.field({ type: Post, args: { - input: t.arg({ required: true, type: CreatePost }) + input: t.arg({ required: true, type: CreatePost }), }, resolve: async (parent, args) => { const author = await prisma.user.findUnique({ - where: { id: Number(args.input.authorId) } + where: { id: Number(args.input.authorId) }, }); if (!author) { throw new Error('Author does not exist!'); @@ -73,23 +73,23 @@ builder.mutationFields((t) => ({ published: args.input.published, author: { connect: { - id: author.id - } - } - } + id: author.id, + }, + }, + }, }); return post; - } + }, }), updatePost: t.field({ type: Post, args: { - input: t.arg({ required: true, type: UpdatePost }) + input: t.arg({ required: true, type: UpdatePost }), }, resolve: async (parent, args) => { const post = await prisma.post.update({ where: { - id: Number(args.input.id) + id: Number(args.input.id), }, data: { title: args.input.title ?? undefined, @@ -98,13 +98,13 @@ builder.mutationFields((t) => ({ ...(args.input.authorId && { author: { connect: { - id: Number(args.input.authorId) - } - } - }) - } + id: Number(args.input.authorId), + }, + }, + }), + }, }); return post; - } - }) -})); \ No newline at end of file + }, + }), +})); diff --git a/src/lib/server/pothos/schema/users.ts b/src/lib/server/pothos/schema/users.ts index c15b8bb..210ad57 100644 --- a/src/lib/server/pothos/schema/users.ts +++ b/src/lib/server/pothos/schema/users.ts @@ -8,33 +8,33 @@ export const User = builder.prismaObject('User', { name: t.exposeString('name'), posts: t.relation('posts'), createdAt: t.expose('createdAt', { - type: 'Date' + type: 'Date', }), updatedAt: t.expose('updatedAt', { - type: 'Date' - }) - }) + type: 'Date', + }), + }), }); const CreateUser = builder.inputType('CreateUser', { fields: (t) => ({ email: t.string({ - required: true + required: true, }), name: t.string({ - required: true - }) - }) + required: true, + }), + }), }); const UpdateUser = builder.inputType('UpdateUser', { fields: (t) => ({ id: t.id({ - required: true + required: true, }), email: t.string(), - name: t.string() - }) + name: t.string(), + }), }); builder.queryFields((t) => ({ @@ -42,42 +42,42 @@ builder.queryFields((t) => ({ type: [User], resolve: async () => { return await prisma.user.findMany(); - } - }) + }, + }), })); builder.mutationFields((t) => ({ createUser: t.field({ type: User, args: { - input: t.arg({ required: true, type: CreateUser }) + input: t.arg({ required: true, type: CreateUser }), }, resolve: async (parent, args) => { const post = await prisma.user.create({ data: { email: args.input.email, - name: args.input.name - } + name: args.input.name, + }, }); return post; - } + }, }), updateUser: t.field({ type: User, args: { - input: t.arg({ required: true, type: UpdateUser }) + input: t.arg({ required: true, type: UpdateUser }), }, resolve: async (parent, args) => { const post = await prisma.user.update({ where: { - id: Number(args.input.id) + id: Number(args.input.id), }, data: { email: args.input.email, - name: args.input.name ?? undefined - } + name: args.input.name ?? undefined, + }, }); return post; - } - }) -})); \ No newline at end of file + }, + }), +})); diff --git a/src/lib/server/prisma/index.ts b/src/lib/server/prisma/index.ts index fbb7b51..9b6c4ce 100644 --- a/src/lib/server/prisma/index.ts +++ b/src/lib/server/prisma/index.ts @@ -1,3 +1,3 @@ import { PrismaClient } from '@prisma/client'; -export const prisma = new PrismaClient(); \ No newline at end of file +export const prisma = new PrismaClient(); diff --git a/src/lib/server/yoga/context.ts b/src/lib/server/yoga/context.ts index 8a3ab51..e7eff70 100644 --- a/src/lib/server/yoga/context.ts +++ b/src/lib/server/yoga/context.ts @@ -3,5 +3,5 @@ import type { YogaInitialContext } from 'graphql-yoga'; export const Context = (initialContext: YogaInitialContext) => ({ ...initialContext, - config: Config -}); \ No newline at end of file + config: Config, +}); diff --git a/src/lib/server/yoga/index.ts b/src/lib/server/yoga/index.ts index b489ffb..8e2b5fb 100644 --- a/src/lib/server/yoga/index.ts +++ b/src/lib/server/yoga/index.ts @@ -1,2 +1,2 @@ export * from './context'; -export * from './server'; \ No newline at end of file +export * from './server'; diff --git a/src/lib/server/yoga/server.ts b/src/lib/server/yoga/server.ts index 4bdfbe6..aa17066 100644 --- a/src/lib/server/yoga/server.ts +++ b/src/lib/server/yoga/server.ts @@ -10,5 +10,5 @@ export const Yoga = createYoga({ graphqlEndpoint: '/api/graphql', // Let Yoga use sveltekit's Response object fetchAPI: { Response }, - logging: yogaLogger -}); \ No newline at end of file + logging: yogaLogger, +}); diff --git a/src/lib/types/daisy-colors.ts b/src/lib/types/daisy-colors.ts index c5d5a56..e8c5062 100644 --- a/src/lib/types/daisy-colors.ts +++ b/src/lib/types/daisy-colors.ts @@ -9,4 +9,4 @@ export type DaisyColor = | 'info' | 'success' | 'warning' - | 'error'; \ No newline at end of file + | 'error'; diff --git a/src/lib/types/daisy-sizes.ts b/src/lib/types/daisy-sizes.ts index 9cd1207..87421d4 100644 --- a/src/lib/types/daisy-sizes.ts +++ b/src/lib/types/daisy-sizes.ts @@ -1 +1 @@ -export type DaisySize = 'xs' | 'sm' | 'lg'; \ No newline at end of file +export type DaisySize = 'xs' | 'sm' | 'lg'; diff --git a/src/lib/types/index.ts b/src/lib/types/index.ts index 93ffa73..282f9e4 100644 --- a/src/lib/types/index.ts +++ b/src/lib/types/index.ts @@ -1,2 +1,2 @@ export * from './daisy-colors'; -export * from './daisy-sizes'; \ No newline at end of file +export * from './daisy-sizes'; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 7725dd4..ae9ad12 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -11,4 +11,4 @@ .layout { @apply h-screen w-screen bg-base-100; } - \ No newline at end of file + diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 3e2a230..bdfb4d6 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -3,15 +3,15 @@ export async function load(event) { const userId = event.cookies.get('user'); if (!userId) { return { - authenticated: false + authenticated: false, }; } const user = await prisma.user.findUnique({ where: { - id: userId - } + id: userId, + }, }); return { - authenticated: !!user + authenticated: !!user, }; } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 42c1ebf..e3c9a34 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -21,4 +21,4 @@ .site-loader { @apply flex h-screen w-screen flex-col items-center justify-center gap-6; } - \ No newline at end of file + diff --git a/src/routes/api/graphql/+server.ts b/src/routes/api/graphql/+server.ts index c208143..e1eead7 100644 --- a/src/routes/api/graphql/+server.ts +++ b/src/routes/api/graphql/+server.ts @@ -1,3 +1,3 @@ import { Yoga } from '$lib/server/yoga'; -export { Yoga as GET, Yoga as POST }; \ No newline at end of file +export { Yoga as GET, Yoga as POST }; diff --git a/src/routes/app/+layout.svelte b/src/routes/app/+layout.svelte index 3e0b9dd..c14e9a4 100644 --- a/src/routes/app/+layout.svelte +++ b/src/routes/app/+layout.svelte @@ -5,4 +5,4 @@ -{@render children()} \ No newline at end of file +{@render children()} diff --git a/src/routes/login/+page.server.ts b/src/routes/login/+page.server.ts index dc69fae..0fea32f 100644 --- a/src/routes/login/+page.server.ts +++ b/src/routes/login/+page.server.ts @@ -12,8 +12,8 @@ export const actions = { } const user = await prisma.user.findUnique({ where: { - email: form.get('email') as string - } + email: form.get('email') as string, + }, }); if (!user) { logger.error('User not found! ${user}'); @@ -31,7 +31,7 @@ export const actions = { const sessionCookie = auth.createSessionCookie(session.id); event.cookies.set(sessionCookie.name, sessionCookie.value, { path: '/', - maxAge: 120 + maxAge: 120, }); redirect(302, '/'); }, @@ -47,8 +47,8 @@ export const actions = { data: { email: form.get('email') as string, name: form.get('name') as string, - password: hashedPassword - } + password: hashedPassword, + }, }); const session = await auth.createSession(user.id.toString(), {}); const sessionCookie = auth.createSessionCookie(session.id); @@ -57,8 +57,8 @@ export const actions = { } event.cookies.set(sessionCookie.name, sessionCookie.value, { path: '/', - maxAge: 120 + maxAge: 120, }); redirect(302, '/'); - } + }, } satisfies Actions; diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index b72fefd..f32bb29 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -23,7 +23,12 @@
- + {#if variant === 'register'} {/if} @@ -47,4 +52,4 @@ .page { @apply flex flex-col items-center justify-around gap-24 py-[10%]; } - \ No newline at end of file + diff --git a/svelte.config.js b/svelte.config.js index 1295460..3ad145a 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -11,8 +11,8 @@ const config = { // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. // If your environment is not supported, or you settled on a specific environment, switch out the adapter. // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter() - } + adapter: adapter(), + }, }; export default config; diff --git a/tailwind.config.ts b/tailwind.config.ts index 065ea6d..0ad0c33 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -8,22 +8,22 @@ export default { theme: { extend: { fontFamily: { - display: ['Baskervville SC'] + display: ['Baskervville SC'], }, animation: { - fade: 'fadeIn .5s ease-in-out' + fade: 'fadeIn .5s ease-in-out', }, keyframes: { fadeIn: { from: { opacity: '0' }, - to: { opacity: '1' } - } - } - } + to: { opacity: '1' }, + }, + }, + }, }, plugins: [typography, daisyui], daisyui: { - logs: false - } -} satisfies Config; \ No newline at end of file + logs: false, + }, +} satisfies Config; diff --git a/vite.config.ts b/vite.config.ts index d76fc8a..40e6b52 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,6 +5,6 @@ export default defineConfig({ plugins: [sveltekit()], test: { - include: ['src/**/*.{test,spec}.{js,ts}'] - } + include: ['src/**/*.{test,spec}.{js,ts}'], + }, }); -- 2.45.3 From 8ba0297cfdc78fe0f8d438b6d1e517ad9ec141ae Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Thu, 19 Dec 2024 21:03:46 -0500 Subject: [PATCH 27/28] blyat --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9df9397..a909d73 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,10 @@ "storybook": "storybook dev -p 6006", "build-storybook": "storybook build", "test:e2e": "playwright test", - "prisma:push": "prisma db push", + "prisma:dev": "prisma migrate dev", "prisma:format": "prisma format", "prisma:generate": "prisma generate", + "prisma:push": "prisma db push", "prisma:reset": "prisma migrate reset --force", "prisma:studio": "prisma studio" }, -- 2.45.3 From 38021f04534ded1d46199568ec953ad322087927 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Thu, 19 Dec 2024 21:16:29 -0500 Subject: [PATCH 28/28] fix redirect --- src/routes/+page.server.ts | 20 ++++++++++---------- src/routes/+page.svelte | 6 ++---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index bdfb4d6..89bd867 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,17 +1,17 @@ import { prisma } from '$lib/server/prisma'; +import { redirect } from '@sveltejs/kit'; export async function load(event) { - const userId = event.cookies.get('user'); - if (!userId) { - return { - authenticated: false, - }; + const sessionId = event.cookies.get('auth_session'); + if (!sessionId) { + redirect(303, '/login'); } - const user = await prisma.user.findUnique({ + const user = await prisma.session.findUnique({ where: { - id: userId, + id: sessionId, }, }); - return { - authenticated: !!user, - }; + if (!user) { + redirect(401, '/login'); + } + return {}; } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index e3c9a34..378f71c 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -3,10 +3,8 @@ import Loader from '$lib/components/common/Loader'; import { fade } from 'svelte/transition'; - let { data } = $props(); - $effect(() => { - const id = setTimeout(() => (data.authenticated ? goto('/app') : goto('/login')), 1500); + const id = setTimeout(() => goto('/app'), 1500); return () => { clearTimeout(id); }; @@ -21,4 +19,4 @@ .site-loader { @apply flex h-screen w-screen flex-col items-center justify-center gap-6; } - + \ No newline at end of file -- 2.45.3