@brahma-dev/abuseipdb-middleware
Version:
Universal middleware for reporting malicious IPs to AbuseIPDB. Supports Elysia, Express, Koa, Fastify, and Hono.
54 lines (46 loc) • 1.84 kB
TypeScript
import { Request, Response, NextFunction } from 'express';
import { Context, Next } from 'koa';
import { FastifyInstance } from 'fastify';
import { Context as Context$1, Next as Next$1 } from 'hono';
import { Elysia } from 'elysia';
interface AbuseIPDBOptions {
apiKey: string;
paths?: string[];
additionalPaths?: string[];
categories?: string;
cacheTTL?: number;
}
declare const abuseIPDBExpress: (options: AbuseIPDBOptions) => {
middleware: (req: Request, res: Response, next: NextFunction) => void;
report: (ip: string, comment: string, reportCategories?: string) => Promise<void>;
};
declare const abuseIPDBKoa: (options: AbuseIPDBOptions) => {
middleware: (ctx: Context, next: Next) => Promise<void>;
report: (ip: string, comment: string, reportCategories?: string) => Promise<void>;
};
interface AbuseIPDBReporter {
report: (ip: string, comment: string, categories?: string) => Promise<void>;
}
declare const abuseIPDBFastify: (fastify: FastifyInstance, options: AbuseIPDBOptions) => Promise<void>;
declare module 'fastify' {
interface FastifyInstance {
abuseipdb: AbuseIPDBReporter;
}
}
declare const abuseIPDBHono: (options: AbuseIPDBOptions) => {
middleware: (c: Context$1, next: Next$1) => Promise<void>;
report: (ip: string, comment: string, reportCategories?: string) => Promise<void>;
};
declare const abuseIPDBElysia: (options: AbuseIPDBOptions) => {
middleware: (app: Elysia) => Elysia<"", {
request: {};
store: {};
derive: {};
resolve: {};
}, {
type: {};
error: {};
}, {}, {}, {}, false>;
report: (ip: string, comment: string, reportCategories?: string) => Promise<void>;
};
export { type AbuseIPDBOptions, abuseIPDBElysia, abuseIPDBExpress, abuseIPDBFastify, abuseIPDBHono, abuseIPDBKoa };