production ready

This commit is contained in:
2026-06-04 18:47:17 +02:00
parent 8524179793
commit aecd49a1bc
10 changed files with 499 additions and 16 deletions
+4 -1
View File
@@ -1,5 +1,6 @@
import { redirect, type Handle } from '@sveltejs/kit';
import { sequence } from '@sveltejs/kit/hooks';
import { PUBLIC_CONVEX_URL } from '$env/static/public';
import {
createConvexAuthHooks,
createRouteMatcher
@@ -10,7 +11,9 @@ const isProtectedRoute = createRouteMatcher([
'/entries{/*rest}',
'/settings{/*rest}'
]);
const { handleAuth, isAuthenticated } = createConvexAuthHooks();
const { handleAuth, isAuthenticated } = createConvexAuthHooks({
convexUrl: PUBLIC_CONVEX_URL
});
const protectRoutes: Handle = async ({ event, resolve }) => {
if (isProtectedRoute(event.url.pathname) && !(await isAuthenticated(event))) {
+4 -1
View File
@@ -1,7 +1,10 @@
import { PUBLIC_CONVEX_URL } from '$env/static/public';
import { createConvexAuthHandlers } from '@mmailaender/convex-auth-svelte/sveltekit/server';
import type { LayoutServerLoad } from './$types.js';
const { getAuthState } = createConvexAuthHandlers();
const { getAuthState } = createConvexAuthHandlers({
convexUrl: PUBLIC_CONVEX_URL
});
export const load: LayoutServerLoad = async (event) => {
return {
+4 -1
View File
@@ -1,8 +1,11 @@
import { PUBLIC_CONVEX_URL } from '$env/static/public';
import { redirect } from '@sveltejs/kit';
import { createConvexAuthHandlers } from '@mmailaender/convex-auth-svelte/sveltekit/server';
import type { PageServerLoad } from './$types.js';
const { isAuthenticated } = createConvexAuthHandlers();
const { isAuthenticated } = createConvexAuthHandlers({
convexUrl: PUBLIC_CONVEX_URL
});
export const load: PageServerLoad = async (event) => {
throw redirect(302, (await isAuthenticated(event)) ? '/dashboard' : '/signin');