bear-tracker
Version:
Lightweight bot detection middleware for tracking AI crawler visits (OpenAI, ChatGPT, etc.) with API support and analytics
46 lines • 1.11 kB
TypeScript
export interface BotInfo {
name: string;
type: 'ai_search' | 'ai_training' | 'ai_user' | 'search_engine' | 'unknown';
isBot: boolean;
userAgent: string;
ip?: string;
timestamp: Date;
description?: string;
}
export interface BotTrackerOptions {
enableLogging?: boolean;
customLogger?: (botInfo: BotInfo) => void;
trackOnlyBots?: boolean;
includeIp?: boolean;
logLevel?: 'info' | 'warn' | 'error';
}
export interface RequestLike {
headers: {
'user-agent'?: string;
[key: string]: string | undefined;
};
ip?: string;
connection?: {
remoteAddress?: string;
};
}
export interface ResponseLike {
locals?: {
[key: string]: any;
};
}
export interface NextFunction {
(): void;
}
export interface NextRequestLike {
headers: {
get(name: string): string | null;
};
ip?: string;
nextUrl: {
hostname: string;
pathname: string;
};
}
export type MiddlewareFunction = (req: RequestLike, res: ResponseLike, next: NextFunction) => void;
//# sourceMappingURL=types.d.ts.map