Avoid generating key inside checkIdentifier

Small formatting changes in .env.example / next.config.js
This commit is contained in:
2023-09-05 10:43:49 -05:00
parent 24b4b678a8
commit 19077faf58
3 changed files with 4 additions and 13 deletions

View File

@@ -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=

View File

@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
reactStrictMode: true
};
module.exports = nextConfig;

View File

@@ -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<boolean> {
return (await redis.get(key)) === '1';
}
export async function markIdentifier(