From ca3d467a142a6dca372c49a237e702874249087f Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 26 Jun 2024 20:58:34 +0500 Subject: [PATCH 1/2] feat: config application (#183) * feat: config * fix: using private env * chore: use config type * chore: remove unused env --- package.json | 3 +- src/hooks.server.ts | 6 +- src/lib/components/Footer.svelte | 15 ++--- src/lib/components/Profile.svelte | 6 +- src/lib/config.ts | 62 +++++++++++++++---- src/lib/game/services/action/actionService.ts | 19 +++--- .../game/services/socket/webSocketService.ts | 4 +- src/lib/server/api.ts | 4 +- src/routes/[lang]/(game)/play/+page.server.ts | 6 +- src/routes/[lang]/(website)/+page.svelte | 4 +- src/routes/auth/profile/+server.ts | 4 +- src/routes/auth/sign-in/+server.ts | 8 +-- yarn.lock | 5 ++ 13 files changed, 89 insertions(+), 57 deletions(-) diff --git a/package.json b/package.json index 8931a24d..27bc1f9b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "howler": "^2.2.4", "jsonwebtoken": "^9.0.2", "lucide-svelte": "^0.396.0", - "pixi.js": "^8.2.0" + "pixi.js": "^8.2.0", + "zod": "^3.23.8" }, "devDependencies": { "@antfu/eslint-config": "^2.21.1", diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 33645019..7acbac64 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,13 +1,13 @@ import { type Handle, redirect } from '@sveltejs/kit' import jwt from 'jsonwebtoken' import { sequence } from '@sveltejs/kit/hooks' -import { env as privateEnv } from '$env/dynamic/private' -import { env as publicEnv } from '$env/dynamic/public' import type { Profile } from '$lib/types' import { type Locale, defaultLocale, supportedLocales } from '$lib/translations' +import { env as privateEnv } from '$env/dynamic/private' +import { config } from '$lib/config' const handleJWT: Handle = ({ event, resolve }) => { - const cookieKey = publicEnv.PUBLIC_COOKIE_KEY ?? '' + const cookieKey = config.cookieKey const jwtSecret = privateEnv.PRIVATE_JWT_SECRET_KEY const token = event.cookies.get(cookieKey) diff --git a/src/lib/components/Footer.svelte b/src/lib/components/Footer.svelte index e6d13dd3..41dba172 100644 --- a/src/lib/components/Footer.svelte +++ b/src/lib/components/Footer.svelte @@ -1,25 +1,20 @@