added support for app plugin hook

This commit is contained in:
Wyatt Johnson
2017-12-19 09:13:01 -07:00
parent 8e1cfc3a29
commit e2d8562868
3 changed files with 34 additions and 8 deletions
+10 -6
View File
@@ -42,14 +42,15 @@ const decorateContextPlugins = (context, contextPlugins) => {
* Stores the request context.
*/
class Context {
constructor({user = null}) {
constructor(parent) {
// Generate a new context id for the request.
this.id = uuid.v4();
// Generate a new context id for the request if the parent doesn't provide
// one.
this.id = parent.id || uuid.v4();
// Load the current logged in user to `user`, otherwise this'll be null.
if (user) {
this.user = user;
// Load the current logged in user to `user`, otherwise this will be null.
if (parent.user) {
this.user = parent.user;
}
// Attach the connectors.
@@ -66,6 +67,9 @@ class Context {
// Bind the publish/subscribe to the context.
this.pubsub = pubsub.getClient();
// Bind the parent context.
this.parent = parent;
}
}