Skip to content

Commit 819666a

Browse files
committed
feat(logging): integrate Pino for structured logging and enhance logging capabilities
- Added comprehensive logging configuration using Pino. - Implemented default and custom logger options for FetchProxy. - Introduced structured logging for request lifecycle, security events, and performance metrics. - Enhanced tests to cover logging integration and error handling in logging. - Removed simple test file and added detailed logging examples. - Updated documentation to include logging configuration guide.
1 parent 30a622f commit 819666a

31 files changed

Lines changed: 2025 additions & 541 deletions

README.md

Lines changed: 170 additions & 73 deletions
Large diffs are not rendered by default.

SECURITY.md

Lines changed: 0 additions & 150 deletions
This file was deleted.

bun.lock

Lines changed: 34 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/API.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# fetch-proxy API Documentation
1+
# fetch-gate API Documentation
22

33
## Table of Contents
44

@@ -12,7 +12,7 @@
1212

1313
## Core API
1414

15-
### `createFetchProxy(options?)`
15+
### `createFetchGate(options?)`
1616

1717
Creates a new fetch proxy instance with the specified configuration.
1818

@@ -32,15 +32,15 @@ Creates a new fetch proxy instance with the specified configuration.
3232
}
3333
```
3434

35-
### `proxy(req, source?, options?)`
35+
### `proxy(req, source?, opts?)`
3636

3737
Proxies an HTTP request to the target server.
3838

3939
**Parameters:**
4040

4141
- `req: Request` - The incoming request object
4242
- `source?: string` - Target URL or path (optional if base is set)
43-
- `options?: ProxyRequestOptions` - Per-request options
43+
- `opts?: ProxyRequestOptions` - Per-request options
4444

4545
**Returns:**
4646

@@ -141,7 +141,7 @@ interface ProxyRequestOptions {
141141

142142
## Hooks
143143

144-
Hooks allow you to intercept and modify requests, responses, and handle errors. fetch-proxy provides enhanced hook naming conventions with better semantics and circuit breaker lifecycle hooks.
144+
Hooks allow you to intercept and modify requests, responses, and handle errors. fetch-gate provides enhanced hook naming conventions with better semantics and circuit breaker lifecycle hooks.
145145

146146
### Enhanced Hooks with Circuit Breaker Monitoring
147147

@@ -247,13 +247,13 @@ When multiple hooks are configured, they execute in this order:
247247

248248
```typescript
249249
const response = await proxy(request, "/users", {
250-
beforeRequest: async (req, options) => {
250+
beforeRequest: async (req, opts) => {
251251
console.log("Making request to:", req.url)
252252
},
253253
afterResponse: async (req, res, body) => {
254254
console.log("Received response:", res.status)
255255
},
256-
beforeCircuitBreakerExecution: async (req, options) => {
256+
beforeCircuitBreakerExecution: async (req, opts) => {
257257
console.log("Circuit breaker executing request")
258258
},
259259
afterCircuitBreakerExecution: async (req, result) => {
@@ -424,4 +424,4 @@ See the [examples directory](../examples/) for complete working examples:
424424
425425
- [Gateway Server](../examples/gateway-server.ts) - Basic proxy server
426426
- [Load Balancer](../examples/load-balancer.ts) - Round-robin load balancing
427-
- [Debug Script](../examples/debug.ts) - Testing and debugging
427+
- [Logging Example](../examples/logger-examples.ts) - Request/response logging

0 commit comments

Comments
 (0)