Skip to content

Commit

Permalink
Merge pull request #10 from blinkafrica/patch/x-request-id
Browse files Browse the repository at this point in the history
patch: fix instances where x-request-id header does not exist in the request header
  • Loading branch information
zerothebahdman authored Apr 9, 2024
2 parents 4c32ba3 + f98e377 commit 0bd9479
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blinkclaud/octobus",
"version": "0.3.1",
"version": "0.4.0",
"description": "A toolkit for Blink HQ's microservices",
"author": "Blink HQ",
"private": false,
Expand Down
10 changes: 4 additions & 6 deletions src/http/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,11 @@ export class RequestWrapper<T extends object> {
* @param req source request if there's any
*/
track(req?: Request) {
// make sure request ID exists for non-base requests
if (req && !req.headers['x-request-id']) {
throw new NoRequestIDError(this.request.url as string);
}

Object.assign(this.request.headers as object, {
'X-Request-ID': !!req ? req.headers['x-request-id'] : v4(),
'X-Request-ID':
!!req && req.headers['x-request-id']
? req.headers['x-request-id']
: v4(),
'X-Origin-Service': this.service,
});

Expand Down

0 comments on commit 0bd9479

Please sign in to comment.