diff --git a/.gitignore b/.gitignore
index ce55f38..cbf6a49 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,4 +17,5 @@ Thumbs.db
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
-*storybook.log
\ No newline at end of file
+*/dev.db
+*/dev.db-journal
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
index 7ebb855..1b5c8a9 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -1,8 +1,14 @@
{
"useTabs": true,
"singleQuote": true,
- "trailingComma": "none",
+ "trailingComma": "es5",
"printWidth": 100,
+ "endOfLine": "lf",
+ "arrowParens": "always",
+ "jsxSingleQuote": false,
+ "semi": true,
+ "quoteProps": "as-needed",
+ "tabWidth": 4,
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
"overrides": [
{
diff --git a/.storybook/main.js b/.storybook/main.js
index f073993..5f0a59a 100644
--- a/.storybook/main.js
+++ b/.storybook/main.js
@@ -2,15 +2,16 @@
const config = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|ts|svelte)'],
addons: [
- '@storybook/addon-svelte-csf',
- '@storybook/addon-essentials',
'@chromatic-com/storybook',
+ '@storybook/addon-essentials',
'@storybook/addon-interactions',
- 'storybook-dark-mode'
+ '@storybook/addon-styling-webpack',
+ '@storybook/addon-svelte-csf',
+ '@storybook/addon-themes',
],
framework: {
name: '@storybook/sveltekit',
- options: {}
- }
+ options: {},
+ },
};
-export default config;
\ No newline at end of file
+export default config;
diff --git a/.storybook/preview.css b/.storybook/preview.css
new file mode 100644
index 0000000..4e7ba75
--- /dev/null
+++ b/.storybook/preview.css
@@ -0,0 +1,4 @@
+@import 'tailwindcss/base';
+@import 'tailwindcss/components';
+@import 'tailwindcss/utilities';
+@import '@flaticon/flaticon-uicons/css/all/all';
diff --git a/.storybook/preview.js b/.storybook/preview.js
index 747af9c..46d380c 100644
--- a/.storybook/preview.js
+++ b/.storybook/preview.js
@@ -1,13 +1,28 @@
+import { withThemeByDataAttribute } from '@storybook/addon-themes';
+import './preview.css';
+
/** @type { import('@storybook/svelte').Preview } */
const preview = {
+ tags: ['autodocs'],
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
- date: /Date$/i
- }
- }
- }
+ date: /Date$/i,
+ },
+ },
+ },
+ decorators: [
+ withThemeByDataAttribute({
+ themes: {
+ light: 'light',
+ dark: 'dark',
+ night: 'night',
+ },
+ defaultTheme: 'dark',
+ attributeName: 'data-theme',
+ }),
+ ],
};
-export default preview;
\ No newline at end of file
+export default preview;
diff --git a/README.md b/README.md
index 8aff12f..6211c61 100644
--- a/README.md
+++ b/README.md
@@ -1,38 +1,69 @@
-# sv
+# Hestia
-Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
+Hestia is an early stage project
-## Creating a project
-
-If you're seeing this, you've probably already done this step. Congrats!
+## Setup
```bash
-# create a new project in the current directory
-bunx sv create
+# install dependencies
+bun install
-# create a new project in my-app
-bunx sv create my-app
+# set up local database
+bun prisma:dev
```
## Developing
-Once you've created a project and installed dependencies with `bun install`, start a development server:
+Once you've created a project and installed dependencies, start a development server:
```bash
-bun run dev
+bun dev
# or start the server and open the app in a new browser tab
-bun run dev -- --open
+bun dev -- --open
+
+# to use storybook for components development
+bun storybook
+
+# interact with local database
+bun prisma:studio
```
+> You can access the Yoga web-app at `/api/graphql`
+
## Building
To create a production version of your app:
```bash
-bun run build
+bun build
```
+## Stack
+
+- https://svelte.dev/docs/kit/introduction
+- https://zod.dev/
+- https://day.js.org/
+
+### Frontend
+
+- https://tailwindcss.com/
+- https://www.flaticon.com/
+- https://daisyui.com/
+
+### Backend
+
+- https://www.prisma.io/
+- https://pothos-graphql.dev/
+- https://the-guild.dev/graphql/yoga-server
+- https://github.com/pinojs/pino
+
+### Tools
+
+- https://storybook.js.org/
+- https://vite.dev/
+- https://vitest.dev/
+
You can preview the production build with `bun run preview`.
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
diff --git a/bun.lockb b/bun.lockb
index 49f3097..3bf4b9d 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/docs/DAISY.md b/docs/DAISY.md
new file mode 100644
index 0000000..1470054
--- /dev/null
+++ b/docs/DAISY.md
@@ -0,0 +1,3 @@
+# Experienced Issues
+
+- https://github.com/saadeghi/daisyui/issues/811
diff --git a/eslint.config.js b/eslint.config.js
index aa5987f..5c68edc 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -18,17 +18,17 @@ export default ts.config(
languageOptions: {
globals: {
...globals.browser,
- ...globals.node
- }
- }
+ ...globals.node,
+ },
+ },
},
{
files: ['**/*.svelte'],
languageOptions: {
parserOptions: {
- parser: ts.parser
- }
- }
+ parser: ts.parser,
+ },
+ },
}
);
diff --git a/package.json b/package.json
index 22de0de..a909d73 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,12 @@
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test:e2e": "playwright test",
- "prisma:generate": "prisma generate"
+ "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"
},
"devDependencies": {
"@chromatic-com/storybook": "^3.2.2",
@@ -23,7 +28,9 @@
"@playwright/test": "^1.45.3",
"@storybook/addon-essentials": "^8.4.7",
"@storybook/addon-interactions": "^8.4.7",
+ "@storybook/addon-styling-webpack": "^1.0.1",
"@storybook/addon-svelte-csf": "^5.0.0-next.13",
+ "@storybook/addon-themes": "^8.4.7",
"@storybook/blocks": "^8.4.7",
"@storybook/svelte": "^8.4.7",
"@storybook/sveltekit": "^8.4.7",
@@ -33,6 +40,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",
@@ -42,7 +50,6 @@
"prettier-plugin-tailwindcss": "^0.6.5",
"prisma": "^6.0.1",
"storybook": "^8.4.7",
- "storybook-dark-mode": "^4.0.2",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"tailwindcss": "^3.4.9",
@@ -52,6 +59,7 @@
"vitest": "^2.0.4"
},
"dependencies": {
+ "@flaticon/flaticon-uicons": "^3.3.1",
"@lucia-auth/adapter-prisma": "^4.0.1",
"@pothos/core": "^4.3.0",
"@pothos/plugin-prisma": "^4.4.0",
diff --git a/playwright.config.ts b/playwright.config.ts
index d76ea26..07b7bd2 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -3,8 +3,8 @@ import { defineConfig } from '@playwright/test';
export default defineConfig({
webServer: {
command: 'npm run build && npm run preview',
- port: 4173
+ port: 4173,
},
- testDir: 'e2e'
+ testDir: 'e2e',
});
diff --git a/postcss.config.js b/postcss.config.js
index 0f77216..7b75c83 100644
--- a/postcss.config.js
+++ b/postcss.config.js
@@ -1,6 +1,6 @@
export default {
plugins: {
tailwindcss: {},
- autoprefixer: {}
- }
+ autoprefixer: {},
+ },
};
diff --git a/prisma/dev.db b/prisma/dev.db
deleted file mode 100644
index 86ecbef..0000000
Binary files a/prisma/dev.db and /dev/null differ
diff --git a/prisma/migrations/20241215222709_removed_issue/migration.sql b/prisma/migrations/20241215222709_removed_issue/migration.sql
deleted file mode 100644
index 1aada7c..0000000
--- a/prisma/migrations/20241215222709_removed_issue/migration.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- Warnings:
-
- - The primary key for the `Post` table will be changed. If it partially fails, the table could be left without primary key constraint.
-
-*/
--- RedefineTables
-PRAGMA defer_foreign_keys=ON;
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_Post" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "title" TEXT NOT NULL,
- "content" TEXT NOT NULL,
- "published" BOOLEAN DEFAULT false,
- "authorId" TEXT NOT NULL,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
-);
-INSERT INTO "new_Post" ("authorId", "content", "createdAt", "id", "published", "title", "updatedAt") SELECT "authorId", "content", "createdAt", "id", "published", "title", "updatedAt" FROM "Post";
-DROP TABLE "Post";
-ALTER TABLE "new_Post" RENAME TO "Post";
-PRAGMA foreign_keys=ON;
-PRAGMA defer_foreign_keys=OFF;
diff --git a/prisma/migrations/20241220011159_init/migration.sql b/prisma/migrations/20241220011159_init/migration.sql
new file mode 100644
index 0000000..bbed9b9
--- /dev/null
+++ b/prisma/migrations/20241220011159_init/migration.sql
@@ -0,0 +1,34 @@
+-- CreateTable
+CREATE TABLE "User" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "email" TEXT,
+ "name" TEXT NOT NULL,
+ "password" TEXT NOT NULL,
+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+-- CreateTable
+CREATE TABLE "Session" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "expiresAt" DATETIME NOT NULL,
+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "userId" TEXT NOT NULL,
+ CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "Post" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "title" TEXT NOT NULL,
+ "content" TEXT NOT NULL,
+ "published" BOOLEAN DEFAULT false,
+ "authorId" TEXT NOT NULL,
+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
+);
+
+-- CreateIndex
+CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index bdf9ac4..4449dae 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -15,34 +15,38 @@ datasource db {
}
model User {
- id String @id @default(uuid())
- email String? @unique
- name String
- password String
- posts Post[]
- sessions Session[]
+ id String @id @default(uuid())
+
+ email String? @unique
+ name String
+ password String
+ posts Post[]
+ sessions Session[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model Session {
- id String @id @default(uuid())
- expiresAt DateTime
- createdAt DateTime @default(now())
- updatedAt DateTime @default(now()) @updatedAt
- userId String
- user User @relation(references: [id], fields: [userId])
+ id String @id @default(uuid())
+
+ expiresAt DateTime
+ user User @relation(references: [id], fields: [userId])
+ userId String
+
+ createdAt DateTime @default(now())
+ updatedAt DateTime @default(now()) @updatedAt
}
-
model Post {
- id String @id @default(uuid())
+ id String @id @default(uuid())
+
title String
content String
published Boolean? @default(false)
author User @relation(references: [id], fields: [authorId])
authorId String
+
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
-}
\ No newline at end of file
+}
diff --git a/src/app.css b/src/app.css
index 414ab1e..6a836a2 100644
--- a/src/app.css
+++ b/src/app.css
@@ -1,19 +1,8 @@
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
+@import '@flaticon/flaticon-uicons/css/all/all';
:root {
- @apply text-slate-800;
+ @apply text-base-content;
}
-
-h1 {
- @apply font-display text-4xl;
-}
-
-h2 {
- @apply font-display text-3xl;
-}
-
-h3 {
- @apply font-display text-2xl;
-}
\ No newline at end of file
diff --git a/src/app.d.ts b/src/app.d.ts
index bb055d9..7cce717 100644
--- a/src/app.d.ts
+++ b/src/app.d.ts
@@ -2,10 +2,9 @@
// for information about these interfaces
declare global {
namespace App {
-
// interface Error {}
interface Locals {
- user: import("lucia").User | null;
+ user: import('lucia').User | null;
session: import('lucia').Session | null;
}
// interface PageData {}
diff --git a/src/lib/components/Button.stories.svelte b/src/lib/components/Button.stories.svelte
deleted file mode 100644
index 9403409..0000000
--- a/src/lib/components/Button.stories.svelte
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/src/lib/components/Button.svelte b/src/lib/components/Button.svelte
deleted file mode 100644
index 2c8737a..0000000
--- a/src/lib/components/Button.svelte
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
\ No newline at end of file
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 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte
deleted file mode 100644
index bb75025..0000000
--- a/src/lib/components/Navbar.svelte
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
Hestia
-
-
-
{title}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/lib/components/Navbar.stories.svelte b/src/lib/components/Navigation/Navbar/Navbar.stories.svelte
similarity index 67%
rename from src/lib/components/Navbar.stories.svelte
rename to src/lib/components/Navigation/Navbar/Navbar.stories.svelte
index fe5c161..d9fa299 100644
--- a/src/lib/components/Navbar.stories.svelte
+++ b/src/lib/components/Navigation/Navbar/Navbar.stories.svelte
@@ -3,10 +3,9 @@
import Navbar from './Navbar.svelte';
const { Story } = defineMeta({
- title: 'Navbar',
+ title: 'Navigation/Navbar',
component: Navbar,
- tags: ['autodocs']
});
-
\ No newline at end of file
+
diff --git a/src/lib/components/Navigation/Navbar/Navbar.svelte b/src/lib/components/Navigation/Navbar/Navbar.svelte
new file mode 100644
index 0000000..c16b463
--- /dev/null
+++ b/src/lib/components/Navigation/Navbar/Navbar.svelte
@@ -0,0 +1,12 @@
+
+
+
+ Hestia
+ {title}
+ Welcome!
+
+
+
diff --git a/src/lib/components/Navigation/Navbar/index.ts b/src/lib/components/Navigation/Navbar/index.ts
new file mode 100644
index 0000000..29b38de
--- /dev/null
+++ b/src/lib/components/Navigation/Navbar/index.ts
@@ -0,0 +1,3 @@
+import Navbar from './Navbar.svelte';
+
+export default Navbar;
diff --git a/src/lib/components/Navigation/Tabs/Tab.svelte b/src/lib/components/Navigation/Tabs/Tab.svelte
new file mode 100644
index 0000000..a30a6ee
--- /dev/null
+++ b/src/lib/components/Navigation/Tabs/Tab.svelte
@@ -0,0 +1,5 @@
+
+
+
diff --git a/src/lib/components/Navigation/Tabs/Tabs.stories.svelte b/src/lib/components/Navigation/Tabs/Tabs.stories.svelte
new file mode 100644
index 0000000..828b063
--- /dev/null
+++ b/src/lib/components/Navigation/Tabs/Tabs.stories.svelte
@@ -0,0 +1,27 @@
+
+
+{#snippet template(args: Partial>)}
+
+{/snippet}
+
+
diff --git a/src/lib/components/Navigation/Tabs/Tabs.svelte b/src/lib/components/Navigation/Tabs/Tabs.svelte
new file mode 100644
index 0000000..a0a7e77
--- /dev/null
+++ b/src/lib/components/Navigation/Tabs/Tabs.svelte
@@ -0,0 +1,36 @@
+
+
+
+ {#each tabs as tab, index}
+ {#key [tab, value]}
+ {
+ value = index;
+ }}
+ />
+ {/key}
+ {/each}
+
diff --git a/src/lib/components/Navigation/Tabs/index.ts b/src/lib/components/Navigation/Tabs/index.ts
new file mode 100644
index 0000000..d4f7fd8
--- /dev/null
+++ b/src/lib/components/Navigation/Tabs/index.ts
@@ -0,0 +1,4 @@
+import Tabs from './Tabs.svelte';
+
+export default Tabs;
+export { default as Tabs } from './Tabs.svelte';
diff --git a/src/lib/components/Navigation/index.ts b/src/lib/components/Navigation/index.ts
new file mode 100644
index 0000000..1c2df11
--- /dev/null
+++ b/src/lib/components/Navigation/index.ts
@@ -0,0 +1,4 @@
+import Navbar from './Navbar';
+import Tabs from './Tabs';
+
+export { Navbar, Tabs };
diff --git a/src/lib/components/common/Button/Button.stories.svelte b/src/lib/components/common/Button/Button.stories.svelte
new file mode 100644
index 0000000..d182565
--- /dev/null
+++ b/src/lib/components/common/Button/Button.stories.svelte
@@ -0,0 +1,44 @@
+
+
+
diff --git a/src/lib/components/common/Button/Button.svelte b/src/lib/components/common/Button/Button.svelte
new file mode 100644
index 0000000..e7c4391
--- /dev/null
+++ b/src/lib/components/common/Button/Button.svelte
@@ -0,0 +1,57 @@
+
+
+
+
+
diff --git a/src/lib/components/common/Button/index.ts b/src/lib/components/common/Button/index.ts
new file mode 100644
index 0000000..14aed5d
--- /dev/null
+++ b/src/lib/components/common/Button/index.ts
@@ -0,0 +1,3 @@
+import Button from './Button.svelte';
+
+export default Button;
diff --git a/src/lib/components/Loader.stories.svelte b/src/lib/components/common/Loader/Loader.stories.svelte
similarity index 72%
rename from src/lib/components/Loader.stories.svelte
rename to src/lib/components/common/Loader/Loader.stories.svelte
index 27ef46b..226cba1 100644
--- a/src/lib/components/Loader.stories.svelte
+++ b/src/lib/components/common/Loader/Loader.stories.svelte
@@ -3,10 +3,9 @@
import Loader from './Loader.svelte';
const { Story } = defineMeta({
- title: 'Loader',
+ title: 'Feedback/Loader',
component: Loader,
- tags: ['autodocs']
});
-
\ No newline at end of file
+
diff --git a/src/lib/components/Loader.svelte b/src/lib/components/common/Loader/Loader.svelte
similarity index 98%
rename from src/lib/components/Loader.svelte
rename to src/lib/components/common/Loader/Loader.svelte
index b855fec..425d59e 100644
--- a/src/lib/components/Loader.svelte
+++ b/src/lib/components/common/Loader/Loader.svelte
@@ -48,4 +48,4 @@
transform: rotate(-360deg);
}
}
-
\ No newline at end of file
+
diff --git a/src/lib/components/common/Loader/index.ts b/src/lib/components/common/Loader/index.ts
new file mode 100644
index 0000000..9623773
--- /dev/null
+++ b/src/lib/components/common/Loader/index.ts
@@ -0,0 +1,3 @@
+import Loader from './Loader.svelte';
+
+export default Loader;
diff --git a/src/lib/components/common/TextInput/TextInput.stories.svelte b/src/lib/components/common/TextInput/TextInput.stories.svelte
new file mode 100644
index 0000000..74eb578
--- /dev/null
+++ b/src/lib/components/common/TextInput/TextInput.stories.svelte
@@ -0,0 +1,45 @@
+
+
+{#snippet icon()}
+
+{/snippet}
+
+
+
+
diff --git a/src/lib/components/common/TextInput/TextInput.svelte b/src/lib/components/common/TextInput/TextInput.svelte
new file mode 100644
index 0000000..affbd2c
--- /dev/null
+++ b/src/lib/components/common/TextInput/TextInput.svelte
@@ -0,0 +1,68 @@
+
+
+
+
+
diff --git a/src/lib/components/common/TextInput/index.ts b/src/lib/components/common/TextInput/index.ts
new file mode 100644
index 0000000..89470e9
--- /dev/null
+++ b/src/lib/components/common/TextInput/index.ts
@@ -0,0 +1,3 @@
+import TextInput from './TextInput.svelte';
+
+export default TextInput;
diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts
deleted file mode 100644
index 1689ba6..0000000
--- a/src/lib/components/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './Navbar.svelte';
\ No newline at end of file
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
new file mode 100644
index 0000000..e8c5062
--- /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';
diff --git a/src/lib/types/daisy-sizes.ts b/src/lib/types/daisy-sizes.ts
new file mode 100644
index 0000000..87421d4
--- /dev/null
+++ b/src/lib/types/daisy-sizes.ts
@@ -0,0 +1 @@
+export type DaisySize = 'xs' | 'sm' | 'lg';
diff --git a/src/lib/types/index.ts b/src/lib/types/index.ts
new file mode 100644
index 0000000..282f9e4
--- /dev/null
+++ b/src/lib/types/index.ts
@@ -0,0 +1,2 @@
+export * from './daisy-colors';
+export * from './daisy-sizes';
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 1a20558..ae9ad12 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -9,6 +9,6 @@
\ No newline at end of file
+
diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts
index 3e2a230..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 2a4c1a0..378f71c 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -1,19 +1,17 @@
-
-
Hestia
+
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 b0005e0..c14e9a4 100644
--- a/src/routes/app/+layout.svelte
+++ b/src/routes/app/+layout.svelte
@@ -1,8 +1,8 @@
-{@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 1eb8b77..f32bb29 100644
--- a/src/routes/login/+page.svelte
+++ b/src/routes/login/+page.svelte
@@ -1,38 +1,50 @@
-
-
Hestia
-
-
+{/snippet}
+
+
+
+
+
+
+ {@render form(tab === 0 ? 'login' : 'register')}
@@ -40,10 +52,4 @@
.page {
@apply flex flex-col items-center justify-around gap-24 py-[10%];
}
- .login {
- @apply w-fit max-w-lg animate-fade rounded-lg bg-white p-8;
- }
- .login > form {
- @apply flex w-full flex-col items-center gap-8 rounded-lg;
- }
-
\ 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 575e6fd..0ad0c33 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 {
@@ -7,19 +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]
-} satisfies Config;
\ No newline at end of file
+ plugins: [typography, daisyui],
+ daisyui: {
+ 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}'],
+ },
});