Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

add express response.locals object to the job context object #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/utils/BatchManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class BatchManager {
duration: null,
html: null,
returnMeta: {},
resLocals: response.locals,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we also include request and app level locals?

Copy link
Contributor

Choose a reason for hiding this comment

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

specifically, should we just spread baseContext into here?

Copy link
Contributor Author

@magicmark magicmark Jun 6, 2018

Choose a reason for hiding this comment

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

Passing in request / response sounds good!

Could pass this is in explicitly - spreading in baseContext sounds good too, at the risk of potentially increasing the public api surface area.

I'll update the PR to do this.

(Side note - unclear what batchMeta is used for? Can this be removed?)

╔═ markl@dev21-uswest1cdevc: ~/oss/hypernova git:(add_response_object_to_context)
╚═ ♪ git --no-pager grep batchMeta
src/utils/BatchManager.js:75:      batchMeta: {},

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's being used.

Copy link
Collaborator

Choose a reason for hiding this comment

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

should we just spread baseContext into here?

We could change line 147 to be

const context = this.getRequestContext(null, token);

It would be a breaking change but then the context passed in would have access to baseContext as well.

The downside is that the whole response object would be made available which means that consumers may be able to hijack the response.

};
return obj;
}, {});
Expand Down