-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
36 lines (30 loc) · 868 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict'
/**
* @module seneca-servicebus-transport
*/
const defaults = require('./defaults')
const hooks = require('./lib/hooks')
const PLUGIN_NAME = 'servicebus-transport'
const TRANSPORT_TYPE = 'servicebus'
const debug = require('debug')('seneca-servicebus-transport')
module.exports = function (opts) {
var seneca = this
var so = seneca.options()
var options = seneca.util.deepextend(defaults, so.transport, opts)
debug('Initializing plugin with options %%O', options.servicebus)
var listener = hooks.listenerHook(seneca)
var client = hooks.clientHook(seneca)
seneca.add({
role: 'transport',
hook: 'listen',
type: TRANSPORT_TYPE
}, listener.hook(options, 'listen'))
seneca.add({
role: 'transport',
hook: 'client',
type: TRANSPORT_TYPE
}, client.hook(options, 'client'))
return {
name: PLUGIN_NAME
}
}