Skip to content

Conversation

@dboskovic
Copy link
Contributor

@dboskovic dboskovic commented May 6, 2025

Summary by mrge

Added a new @flatfile/http-logger package to log HTTP and fetch requests in Node.js, including request/response sizes, status codes, and streaming detection.

  • New Features
    • Instruments Node HTTP/HTTPS modules and fetch to log requests automatically.
    • Supports manual logging and auto-initialization.
    • Provides TypeScript types and documentation.

@promptless
Copy link

promptless bot commented May 6, 2025

📝 Documentation updates detected! You can review documentation updates here

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mrge found 8 issues across 4 files. View them in mrge.io


| Parameter | Type | Description |
|-----------|------|-------------|
| `logData.error` | boolean | Whether the request resulted in an error |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error parameter is marked as required in the README table but is optional in the code

| `logData.method` | string | HTTP method used (GET, POST, etc.) |
| `logData.url` | string | Request URL |
| `logData.startTime` | Date | When the request started |
| `logData.headers` | Object | Response headers |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The headers parameter is marked as required in the README table but is optional in the code

| `logData.startTime` | Date | When the request started |
| `logData.headers` | Object | Response headers |
| `logData.statusCode` | number | Response status code |
| `logData.requestSize` | number | Size of request in bytes |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requestSize parameter is marked as required in the README table but is optional in the code

| `logData.headers` | Object | Response headers |
| `logData.statusCode` | number | Response status code |
| `logData.requestSize` | number | Size of request in bytes |
| `logData.responseSize` | number | Size of response in bytes |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The responseSize parameter is marked as required in the README table but is optional in the code

| `logData.statusCode` | number | Response status code |
| `logData.requestSize` | number | Size of request in bytes |
| `logData.responseSize` | number | Size of response in bytes |
| `logData.isStreaming` | boolean | Whether this is a streaming response |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isStreaming parameter is marked as required in the README table but is optional in the code

const chunkSize = Buffer.isBuffer(chunk) ? chunk.length : Buffer.byteLength(chunk, encoding || 'utf8')
requestSize += chunkSize
}
return originalWrite.apply(this, arguments)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using arguments object directly is discouraged in modern JavaScript. Consider using rest parameters

}
}

// eslint-disable-next-line
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eslint-disable comments should specify which rule is being disabled

}

// eslint-disable-next-line
requestLogger(require("http"))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using require() in an ES module can cause compatibility issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant