mirror of
https://github.com/Xevion/bus-reminder.git
synced 2025-12-06 09:14:32 -06:00
Avoid generating key inside checkIdentifier
Small formatting changes in .env.example / next.config.js
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# The password for the online interface (required)
|
# The key used for the online interface & API endpoints (required)
|
||||||
API_KEY=
|
API_KEY=
|
||||||
# Cronitor Account Credentials (required)
|
# Cronitor Account Credentials (required)
|
||||||
CRONITOR_ACCOUNT_ID=
|
CRONITOR_ACCOUNT_ID=
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = nextConfig;
|
||||||
|
|||||||
13
src/db.ts
13
src/db.ts
@@ -28,17 +28,8 @@ export function getKey(identifier: string, now: Date) {
|
|||||||
return format(now, 'yyyy-MM-dd') + ':' + identifier;
|
return format(now, 'yyyy-MM-dd') + ':' + identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO; Move away from generating key inside these functions while also returning it.
|
export async function checkIdentifier(key: string): Promise<boolean> {
|
||||||
|
return (await redis.get(key)) === '1';
|
||||||
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 markIdentifier(
|
export async function markIdentifier(
|
||||||
|
|||||||
Reference in New Issue
Block a user