Skip to content

Scheduling infrastructure for absolutely everyone.

fix: rename dateInPast -> dateNotInPast

Agusti Fernandez Pardo368e6eb0fa83
diff --git a/lib/helpers/verifyApiKey.ts b/lib/helpers/verifyApiKey.ts
index 77eaf7e4cb4..6a8c24df4e7 100644
--- a/lib/helpers/verifyApiKey.ts
+++ b/lib/helpers/verifyApiKey.ts
@@ -12,7 +12,7 @@ declare module "next" {
}
// Used to check if the API key is not expired, could be extracted if reused. but not for now.
-export const dateInPast = function (date: Date) {
+export const dateNotInPast = function (date: Date) {
const now = new Date();
if (now.setHours(0, 0, 0, 0) <= date.setHours(0, 0, 0, 0)) {
return true;
@@ -30,7 +30,7 @@ export const verifyApiKey: NextMiddleware = async (req, res, next) => {
const apiKey = await prisma.apiKey.findUnique({ where: { hashedKey } });
// If we cannot find any api key. Throw a 401 Unauthorized.
if (!apiKey) return res.status(401).json({ error: "Your api key is not valid" });
- if (apiKey.expiresAt && dateInPast(apiKey.expiresAt)) {
+ if (apiKey.expiresAt && dateNotInPast(apiKey.expiresAt)) {
return res.status(401).json({ error: "This api key is expired" });
}
if (!apiKey.userId) return res.status(404).json({ error: "No user found for this api key" });