Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions packages/http-logger/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* HTTP request log data interface
*/
export interface HttpLogData {
/**
* Whether the request resulted in an error
*/
error?: boolean

/**
* HTTP method used (GET, POST, etc.)
*/
method: string

/**
* Request URL
*/
url: string

/**
* When the request started
*/
startTime: Date

/**
* Response headers
*/
headers?: Record<string, string> | Headers

/**
* Response status code
*/
statusCode: number

/**
* Size of request in bytes
*/
requestSize?: number

/**
* Size of response in bytes
*/
responseSize?: number

/**
* Whether this is a streaming response
*/
isStreaming?: boolean
}

/**
* Global logger type definition for extending NodeJS.Global
*/
declare global {
var httpLogger:
| ((logData: {
url: string
method: string
duration: number
statusCode: number
requestSize: number
responseSize: number
isStreaming?: boolean
}) => void)
| undefined
}

/**
* Logs HTTP request details to both Flatfile's internal debugger and any global HTTP logger.
* @param logData - HTTP request log data
*/
export function logHttpRequest(logData: HttpLogData): void

/**
* Instruments HTTP requests to log them to the console.
* Automatically patches Node's HTTP/HTTPS modules and global fetch to track and log requests.
* This is useful for debugging HTTP interactions.
*/
export function instrumentRequests(): void
Loading
Loading