UNPKG

node-lens

Version:

Lens is a lightweight developer tool for Node.js apps that lets you log, view, and debug requests and other activity in real time — inspired by Laravel Telescope.

45 lines (41 loc) 1.55 kB
type EntryHeaders = Record<string, number | string | string[] | undefined>; type LogRequest = { type: 'request'; requestId: string; timestamp: number; method: string; path: string; status: number; durationMs: number; ip: string; memoryUsageMb: number; request: { headers: EntryHeaders; body?: string; }; response: { headers: EntryHeaders; body?: string; }; }; type LogRequestInput = Omit<LogRequest, 'timestamp' | 'type'>; type LogQuery = { type: 'query'; timestamp: number; query: string; durationMs: number; requestId?: string; }; type LogQueryInput = Omit<LogQuery, 'timestamp' | 'type'>; type LogEntry = LogRequest | LogQuery; declare function clear(): void; declare function logRequest(data: LogRequestInput): void; declare function logQuery(data: LogQueryInput): void; declare function getRequests(): LogRequest[]; declare function getQueries(): LogQuery[]; declare function getRequestById(id: string): LogRequest | undefined; declare function getRequestQueries(requestId: string): LogQuery[]; declare function getRecentRequests(limit?: number): LogRequest[]; declare function getRecentQueries(limit?: number): LogQuery[]; declare function getQueryByRequestId(id: string): LogQuery | undefined; export { type LogEntry, type LogQuery, type LogQueryInput, type LogRequest, type LogRequestInput, clear, getQueries, getQueryByRequestId, getRecentQueries, getRecentRequests, getRequestById, getRequestQueries, getRequests, logQuery, logRequest };