forked from otaviosoares/seneca-servicebus-transport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (37 loc) · 959 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
37
38
39
40
41
42
43
'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 = 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);
console.log('Initializing Service Bus');
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
};
};