feat: end to end api type safety with redis rate limiting (#573)
* feat: support hono rpc * add wrangler file * update name of wrangler file * add wrangler as a dependency * add compatibility_flags * trigger ci * core: add health check to docker file * expose port 80 * update custom healthcheck * feat: implement openapi * install dependencies in root * debug yml * update yml * update port * update dockerfile with envs * completely move away from apiClient * rename backend to api * refactor: update server descriptions and comment out local spec saving * update lock file * use api.classroomio.com * add support for redis * fix: add missing line break in WelcomeModal.svelte * refactor: remove wrangler configuration and update Vite config for API integration
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// Default time window for rate limiting (1 minute in milliseconds)
|
||||
export const DEFAULT_WINDOW_MS = 60 * 1000;
|
||||
|
||||
export const DEFAULT_MAX_REQUESTS = 100;
|
||||
|
||||
export const RATE_LIMIT_KEY_PREFIX = 'rate_limit:';
|
||||
|
||||
export const DEFAULT_RATE_LIMITER_OPTIONS = {
|
||||
windowMs: DEFAULT_WINDOW_MS,
|
||||
maxRequests: DEFAULT_MAX_REQUESTS,
|
||||
skipSuccessfulRequests: false,
|
||||
skipFailedRequests: false,
|
||||
message: 'Rate limit exceeded. Please try again later.',
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false
|
||||
} as const;
|
||||
|
||||
export const HTTP_STATUS = {
|
||||
TOO_MANY_REQUESTS: 429
|
||||
} as const;
|
||||
|
||||
export const ERROR_MESSAGES = {
|
||||
RATE_LIMIT_EXCEEDED: 'Too Many Requests',
|
||||
REDIS_PIPELINE_FAILED: 'Redis pipeline execution failed'
|
||||
} as const;
|
||||
|
||||
export const RATE_LIMIT_HEADERS = {
|
||||
LIMIT: 'X-RateLimit-Limit',
|
||||
REMAINING: 'X-RateLimit-Remaining',
|
||||
RESET: 'X-RateLimit-Reset',
|
||||
RETRY_AFTER: 'Retry-After'
|
||||
} as const;
|
||||
Reference in New Issue
Block a user