feat: convert to nextjs

This commit is contained in:
2024-12-07 07:45:24 +01:00
parent b248ee80ee
commit 633b8ee207
52 changed files with 4121 additions and 982 deletions

27
utils/rateLimiter.ts Normal file
View File

@@ -0,0 +1,27 @@
import prisma from '../prisma/prisma';
export async function rateLimiter() {
if (!process.env.RATE_LIMIT) {
throw Error('Rate limit missing.');
}
const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000);
const consumersCount = await prisma.consumer.count({
where: {
createdAt: {
gt: yesterday
}
}
});
const purchaseListsCount = await prisma.purchaseList.count({
where: {
createdAt: {
gt: yesterday
}
}
});
return consumersCount + purchaseListsCount > parseInt(process.env.RATE_LIMIT);
}