-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: don't swallow send error, send error has precedence over other e…
…xtension errors
- Loading branch information
Showing
5 changed files
with
160 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict' | ||
|
||
const Hemera = require('./../../packages/hemera') | ||
const nats = require('nats').connect() | ||
|
||
const hemera = new Hemera(nats, { | ||
logLevel: 'info' | ||
}) | ||
|
||
hemera.ready(() => { | ||
hemera.ext('onServerPreRequest', function(hemera, request, reply, next) { | ||
console.log('onServerPreRequest') | ||
next() | ||
}) | ||
hemera.ext('onServerPreHandler', function(hemera, request, reply, next) { | ||
console.log('onServerPreHandler') | ||
next() | ||
}) | ||
hemera.ext('onServerPreResponse', function(hemera, request, reply, next) { | ||
console.log('onServerPreResponse') | ||
next() | ||
}) | ||
|
||
hemera.add( | ||
{ | ||
topic: 'math', | ||
cmd: 'add' | ||
}, | ||
function(req, cb) { | ||
cb(null, req.a + req.b) | ||
} | ||
) | ||
|
||
hemera.act( | ||
{ | ||
topic: 'math', | ||
cmd: 'add', | ||
a: 1, | ||
b: 20 | ||
}, | ||
function(err, resp) { | ||
if (err) { | ||
this.log.error(err) | ||
return | ||
} | ||
this.log.info(resp) | ||
} | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters