feat: introduce Gatekeeper application, Directus utilities, and monorepo configuration for linting, testing, and husky hooks.
This commit is contained in:
@@ -3,7 +3,11 @@ const submissions: Record<string, number> = {};
|
||||
const RATE_LIMIT_WINDOW = 60 * 60 * 1000; // 1 hour
|
||||
const MAX_SUBMISSIONS_PER_WINDOW = 3;
|
||||
|
||||
export async function rateLimit(identifier: string, windowMs = RATE_LIMIT_WINDOW, maxSubmissions = MAX_SUBMISSIONS_PER_WINDOW) {
|
||||
export async function rateLimit(
|
||||
identifier: string,
|
||||
windowMs = RATE_LIMIT_WINDOW,
|
||||
maxSubmissions = MAX_SUBMISSIONS_PER_WINDOW,
|
||||
) {
|
||||
const now = Date.now();
|
||||
|
||||
// Clean up old submissions
|
||||
@@ -15,7 +19,7 @@ export async function rateLimit(identifier: string, windowMs = RATE_LIMIT_WINDOW
|
||||
|
||||
// Check if identifier has exceeded submission limit
|
||||
const currentSubmissions = Object.values(submissions).filter(
|
||||
(timestamp) => now - timestamp <= windowMs
|
||||
(timestamp) => now - timestamp <= windowMs,
|
||||
);
|
||||
|
||||
if (currentSubmissions.length >= maxSubmissions) {
|
||||
@@ -35,3 +39,4 @@ export function isValidLang(lang: string): lang is Lang {
|
||||
|
||||
export * from "./i18n";
|
||||
export * from "./env";
|
||||
export * from "./directus";
|
||||
|
||||
Reference in New Issue
Block a user