From 19077faf58466f347533dca576cac939683cddac Mon Sep 17 00:00:00 2001 From: Xevion Date: Tue, 5 Sep 2023 10:43:49 -0500 Subject: [PATCH] Avoid generating key inside checkIdentifier Small formatting changes in .env.example / next.config.js --- .env.example | 2 +- next.config.js | 2 +- src/db.ts | 13 ++----------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.env.example b/.env.example index 839e686..99a7f97 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -# The password for the online interface (required) +# The key used for the online interface & API endpoints (required) API_KEY= # Cronitor Account Credentials (required) CRONITOR_ACCOUNT_ID= diff --git a/next.config.js b/next.config.js index 91ef62f..b8e3b7b 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - reactStrictMode: true, + reactStrictMode: true }; module.exports = nextConfig; diff --git a/src/db.ts b/src/db.ts index 3b5d51f..bf3aa41 100644 --- a/src/db.ts +++ b/src/db.ts @@ -28,17 +28,8 @@ export function getKey(identifier: string, now: Date) { return format(now, 'yyyy-MM-dd') + ':' + identifier; } -// TODO; Move away from generating key inside these functions while also returning it. - -export async function checkIdentifier( - identifier: string, - now: Date = new Date() -): Promise<{ marked: boolean; key: string }> { - const key = getKey(identifier, now); - return { - marked: (await redis.get(key)) === '1', - key - }; +export async function checkIdentifier(key: string): Promise { + return (await redis.get(key)) === '1'; } export async function markIdentifier(