diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index bf2bb31..f53cbf8 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -20,4 +20,4 @@ jobs: - name: Build run: bun run build - name: Prisma Schema Check - run: bun prisma:validate \ No newline at end of file + run: bun prisma:validate diff --git a/README.md b/README.md index 6211c61..35bbf0a 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ bun build - https://svelte.dev/docs/kit/introduction - https://zod.dev/ - https://day.js.org/ +- https://inlang.com/c/svelte ### Frontend diff --git a/bun.lockb b/bun.lockb index 3bf4b9d..a50918c 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/messages/en.json b/messages/en.json new file mode 100644 index 0000000..8651435 --- /dev/null +++ b/messages/en.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://inlang.com/schema/inlang-message-format", + "greeting": "Hello {name}!" +} diff --git a/package.json b/package.json index 9bf4669..6f5af34 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@storybook/test": "^8.4.7", "@sveltejs/adapter-auto": "^3.0.0", "@sveltejs/kit": "^2.9.0", - "@sveltejs/vite-plugin-svelte": "^5.0.0", + "@sveltejs/vite-plugin-svelte": "^5.0.3", "@types/bun": "^1.1.14", "autoprefixer": "^10.4.20", "daisyui": "^4.12.22", @@ -61,6 +61,7 @@ }, "dependencies": { "@flaticon/flaticon-uicons": "^3.3.1", + "@inlang/paraglide-sveltekit": "^0.15.0", "@lucia-auth/adapter-prisma": "^4.0.1", "@pothos/core": "^4.3.0", "@pothos/plugin-prisma": "^4.4.0", @@ -76,4 +77,4 @@ "tailwind-merge": "^2.5.5", "zod": "^3.24.0" } -} \ No newline at end of file +} diff --git a/playwright.config.ts b/playwright.config.ts index 01da0bd..b827979 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -7,4 +7,4 @@ export default defineConfig({ }, testDir: 'e2e', -}); \ No newline at end of file +}); diff --git a/project.inlang/.gitignore b/project.inlang/.gitignore new file mode 100644 index 0000000..5e46596 --- /dev/null +++ b/project.inlang/.gitignore @@ -0,0 +1 @@ +cache \ No newline at end of file diff --git a/project.inlang/project_id b/project.inlang/project_id new file mode 100644 index 0000000..dee7877 --- /dev/null +++ b/project.inlang/project_id @@ -0,0 +1 @@ +309efd37fde7fcb319e88bd3fa47f3ff10e868625e8bd1771591d658e463f28f \ No newline at end of file diff --git a/project.inlang/settings.json b/project.inlang/settings.json new file mode 100644 index 0000000..d602d98 --- /dev/null +++ b/project.inlang/settings.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://inlang.com/schema/project-settings", + "modules": [ + "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@1/dist/index.js", + "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-identical-pattern@1/dist/index.js", + "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@1/dist/index.js", + "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@1/dist/index.js", + "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-valid-js-identifier@1/dist/index.js", + "https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@2/dist/index.js", + "https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@0/dist/index.js" + ], + "plugin.inlang.messageFormat": { + "pathPattern": "./messages/{languageTag}.json" + }, + "sourceLanguageTag": "en", + "languageTags": ["en"] +} diff --git a/src/lib/components/Navigation/Navbar/Navbar.svelte b/src/lib/components/Navigation/Navbar/Navbar.svelte index f3f1bc8..4b989d8 100644 --- a/src/lib/components/Navigation/Navbar/Navbar.svelte +++ b/src/lib/components/Navigation/Navbar/Navbar.svelte @@ -1,13 +1,15 @@ + + + diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 8ff2993..bff4064 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,18 +1,5 @@ -import { prisma } from '$lib/server/prisma'; -import { redirect } from '@sveltejs/kit'; +import { validateSession } from '$lib/server/auth'; export async function load(event) { - const sessionId = event.cookies.get('auth_session'); - if (!sessionId) { - redirect(303, '/login'); - } - const user = await prisma.session.findUnique({ - where: { - id: sessionId, - }, - }); - if (!user) { - redirect(300, '/login'); - } - return {}; -} + await validateSession(event); +} \ No newline at end of file diff --git a/src/routes/app/+layout.server.ts b/src/routes/app/+layout.server.ts index dfefb8f..b831d3e 100644 --- a/src/routes/app/+layout.server.ts +++ b/src/routes/app/+layout.server.ts @@ -1,25 +1,9 @@ -import { prisma } from '$lib/server/prisma'; -import { redirect } from '@sveltejs/kit'; -import dayjs from 'dayjs'; +import { validateSession } from '$lib/server/auth'; export async function load(event) { - const sessionId = event.cookies.get('auth_session'); - if (!sessionId) { - redirect(300, '/login'); - } - const session = await prisma.session.findUnique({ - where: { id: sessionId }, - include: { user: true }, - }); - if (!session) { - redirect(300, '/login'); - } - const expiry = session.expiresAt; - if (dayjs(expiry).isBefore(dayjs())) { - redirect(300, '/login'); - } - - const { password: _, ...rest } = session.user; + const { + user: { password: _, ...rest }, + } = await validateSession(event); return { user: rest, }; diff --git a/src/routes/app/+layout.svelte b/src/routes/app/+layout.svelte index 8429527..94df874 100644 --- a/src/routes/app/+layout.svelte +++ b/src/routes/app/+layout.svelte @@ -14,4 +14,4 @@ -{@render children()} \ No newline at end of file +{@render children()} diff --git a/vite.config.ts b/vite.config.ts index 40e6b52..c1e2142 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,8 +1,15 @@ import { defineConfig } from 'vitest/config'; +import { paraglide } from '@inlang/paraglide-sveltekit/vite'; import { sveltekit } from '@sveltejs/kit/vite'; export default defineConfig({ - plugins: [sveltekit()], + plugins: [ + sveltekit(), + paraglide({ + project: './project.inlang', + outdir: './src/lib/paraglide', + }), + ], test: { include: ['src/**/*.{test,spec}.{js,ts}'],