1 | var request = require("superagent");
|
2 |
|
3 | var register = function(config){
|
4 | if(config.pulse && config.pulse.shouldRegister && config.pulse.serviceUrl && config.pulse.communicatorUrl){
|
5 | var body = {
|
6 | "name": config.pulse.serviceName,
|
7 | "message":"PULSE",
|
8 | "scope":"*",
|
9 | "path": config.pulse.path
|
10 | };
|
11 |
|
12 | request
|
13 | .post(config.pulse.communicatorUrl)
|
14 | .send(body)
|
15 | .set('Authorization', config.pulse.token)
|
16 | .end(function(err, response){
|
17 | if (err || !response.ok) {
|
18 | console.log("Failed to register service to " + config.pulse.serviceUrl);
|
19 | }
|
20 | else {
|
21 | console.log("Register service succeeded to " + config.pulse.serviceUrl);
|
22 | }
|
23 | });
|
24 | }
|
25 | };
|
26 |
|
27 | module.exports = register;
|