feat: rebrand Hemmelig to paste.es for cloudhost.es
- Set Spanish as default language with ephemeral/encrypted privacy focus - Translate all user-facing strings and legal pages to Spanish - Replace Norwegian flag with Spanish flag in footer - Remove Hemmelig/terces.cloud links, add cloudhost.es sponsorship - Rewrite PrivacyPage: zero data collection, ephemeral design emphasis - Rewrite TermsPage: Spanish law, RGPD, paste.es/CloudHost.es references - Update PWA manifest, HTML meta tags, package.json branding - Rename webhook headers to X-Paste-Event / X-Paste-Signature - Update API docs title and contact to paste.es / cloudhost.es Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
32
api/middlewares/ratelimit.ts
Normal file
32
api/middlewares/ratelimit.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Context, Next } from 'hono';
|
||||
import { rateLimiter } from 'hono-rate-limiter';
|
||||
import settingsCache from '../lib/settings';
|
||||
import { getClientIp } from '../lib/utils';
|
||||
|
||||
let rateLimitInstance: ReturnType<typeof rateLimiter> | null = null;
|
||||
|
||||
const ratelimit = async (c: Context, next: Next) => {
|
||||
const instanceSettings = settingsCache.get('instanceSettings');
|
||||
|
||||
if (instanceSettings?.enableRateLimiting) {
|
||||
if (rateLimitInstance === null) {
|
||||
rateLimitInstance = rateLimiter({
|
||||
windowMs: instanceSettings.rateLimitWindow * 1000, // Convert seconds to milliseconds
|
||||
limit: instanceSettings.rateLimitRequests,
|
||||
standardHeaders: true,
|
||||
keyGenerator: (c) => getClientIp(c) || 'anonymous',
|
||||
});
|
||||
}
|
||||
|
||||
return rateLimitInstance(c, next);
|
||||
}
|
||||
|
||||
// If rate limiting is disabled, ensure the limiter is cleared
|
||||
if (rateLimitInstance !== null) {
|
||||
rateLimitInstance = null;
|
||||
}
|
||||
|
||||
await next();
|
||||
};
|
||||
|
||||
export default ratelimit;
|
||||
Reference in New Issue
Block a user