From 6d93b24a9a7df769b377b38a815dcc9f6b3d38c1 Mon Sep 17 00:00:00 2001 From: Xevion Date: Mon, 27 Feb 2023 19:06:12 -0600 Subject: [PATCH] Allow returning raw configuration from fetchConfiguration --- src/db.ts | 8 ++++++-- src/pages/login.tsx | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/db.ts b/src/db.ts index 4c24fe5..6d5234d 100644 --- a/src/db.ts +++ b/src/db.ts @@ -6,14 +6,18 @@ import { format } from 'date-fns'; const redis = new Redis(env.REDIS_URL, { maxRetriesPerRequest: 2 }); export async function fetchConfiguration( - defaultConfig?: object + defaultConfig?: object, + getParsed = true ): Promise { const config = await redis.get('config'); if (config == null) if (defaultConfig != undefined) return ConfigurationSchema.parse(defaultConfig); else throw new Error('Configuration not found in Redis'); - return ConfigurationSchema.parse(JSON.parse(config)); + + const json = JSON.parse(config); + const parsed = ConfigurationSchema.parse(json); + return getParsed ? parsed : json; } export function getKey(identifier: string, now: Date) { diff --git a/src/pages/login.tsx b/src/pages/login.tsx index 76c3ff8..fb70280 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -17,7 +17,6 @@ const LoginPage: NextPage = () => { router.push({pathname: "/", query: {"key": data.token}}).then(); } else setError(true); - console.log(response); } return