mirror of
https://github.com/Xevion/bus-reminder.git
synced 2025-12-06 01:14:30 -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=
|
||||
# Cronitor Account Credentials (required)
|
||||
CRONITOR_ACCOUNT_ID=
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
reactStrictMode: true
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// 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(
|
||||
|
||||
Reference in New Issue
Block a user