-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (36 loc) · 897 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
44
var hydraExpress = require('fwsp-hydra-express');
var hydra = hydraExpress.getHydra();
var config = require('./config.json');
function callHelloService() {
let message = hydra.createUMFMessage({
to: 'hello:[get]/',
from: 'home:/',
body: {}
});
return hydra.makeAPIRequest(message);
}
function onRegisterRoutes() {
var express = hydraExpress.getExpress();
var api = express.Router();
api.get('/', function (req, res) {
res.send(`
<h1>Home</h1>
<a href="/test">Test Page</a>
`);
});
api.get('/test', function (req, res) {
callHelloService().then((response) => {
console.log('response', response);
res.send(`
<h1>Test Page</h1>
<p>Message: ${response.msg}</p>
`);
});
});
hydraExpress.registerRoutes({
'': api
});
}
hydraExpress.init(config, onRegisterRoutes)
.then((serviceInfo) => {
});