mirror of
https://github.com/lancedb/lancedb.git
synced 2026-05-22 06:20:39 +00:00
Adds client-side middleware to LanceDB Node SDK to instrument HTTP
Requests
Example - adding `x-request-id` request header:
```js
class HttpMiddleware {
constructor({ requestId }) {
this.requestId = requestId
}
onRemoteRequest(req, next) {
req.headers['x-request-id'] = this.requestId
return next(req)
}
}
const db = await lancedb.connect({
uri: 'db://remote-123',
apiKey: 'sk_...',
})
let tables = await db.withMiddleware(new HttpMiddleware({ requestId: '123' })).tableNames();
```
---------
Co-authored-by: Weston Pace <weston.pace@gmail.com>