Skip to content

Commit 0c5a1f1

Browse files
committed
feat: added bull to app.context
1 parent 8ec9304 commit 0c5a1f1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class API {
3232
constructor(config) {
3333
this.config = {
3434
...sharedConfig('API'),
35+
// <https://github.com/ladjs/bull>
36+
// this is an instance of bull passed to context
37+
// so users can use it in routes, e.g. `ctx.bull`
38+
bull: false,
3539
...config
3640
};
3741

@@ -79,6 +83,10 @@ class API {
7983
// <https://github.com/sindresorhus/eslint-plugin-unicorn/issues/174>
8084
app.context.onerror = errorHandler;
8185

86+
// set bull to be shared throughout app context
87+
// (very useful for not creating additional connections)
88+
if (this.config.bull) app.context.bull = this.config.bull;
89+
8290
// adds request received hrtime and date symbols to request object
8391
// (which is used by Cabin internally to add `request.timestamp` to logs
8492
app.use(requestReceived);

0 commit comments

Comments
 (0)