mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
fix(api): bound http server limits and shed on overload (#2170)
This commit is contained in:
1 parent
a2d7f5e8cc
commit
b26748a2a7
11 files changed
+230
-3
No files matched your search
@@ -9,6 +9,7 @@ import {resolveClientIpHeaderName} from '@fluxer/ip_utils/src/ClientIp';
|
||||
import type {ILogger} from '../ILogger';
|
||||
import {ClientErrorAbuseSignalMiddleware} from '../middleware/AbusiveIpAutoBanner';
|
||||
import {AuditLogMiddleware} from '../middleware/AuditLogMiddleware';
|
||||
import {ConcurrencyLimitMiddleware} from '../middleware/ConcurrencyLimitMiddleware';
|
||||
import ContentFilterMiddleware from '../middleware/ContentFilterMiddleware';
|
||||
import {GuildAvailabilityMiddleware} from '../middleware/GuildAvailabilityMiddleware';
|
||||
import {IpBanMiddleware} from '../middleware/IpBanMiddleware';
|
||||
@@ -27,10 +28,11 @@ interface MiddlewarePipelineOptions {
|
||||
corsOrigins: Array<string>;
|
||||
trustClientIpHeader: boolean;
|
||||
clientIpHeaderName?: string;
|
||||
maxInflightRequests: number;
|
||||
}
|
||||
|
||||
export function configureMiddleware(routes: HonoApp, options: MiddlewarePipelineOptions): void {
|
||||
const {logger, nodeEnv, corsOrigins, trustClientIpHeader, clientIpHeaderName} = options;
|
||||
const {logger, nodeEnv, corsOrigins, trustClientIpHeader, clientIpHeaderName, maxInflightRequests} = options;
|
||||
const resolvedHeader = resolveClientIpHeaderName(clientIpHeaderName);
|
||||
routes.use('/webhooks/:webhook_id/:token', cors({origins: '*'}));
|
||||
routes.use('/webhooks/:webhook_id/:token/messages/:message_id', cors({origins: '*'}));
|
||||
@@ -40,6 +42,7 @@ export function configureMiddleware(routes: HonoApp, options: MiddlewarePipeline
|
||||
skipLogger: true,
|
||||
skipErrorHandler: true,
|
||||
});
|
||||
routes.use(ConcurrencyLimitMiddleware({maxInflightRequests}));
|
||||
routes.get('/_health', async (ctx) => ctx.text('OK'));
|
||||
routes.use(IpBanMiddleware);
|
||||
routes.use(
|
||||
|
||||
Reference in new issue
Block a user