forked from tsnolan23/tailor-react-spa
-
Notifications
You must be signed in to change notification settings - Fork 2
/
microservices.js
36 lines (31 loc) · 847 Bytes
/
microservices.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
const Tailor = require('node-tailor')
const filterReqHeadersFn = require('node-tailor/lib/filter-headers.js')
module.exports = ({ agent }, tracer) => {
return new Tailor({
handledTags: ['script'],
filterRequestHeaders(attributes, request) {
return {
...filterReqHeadersFn(attributes, request),
'Custom-header': 12312312312
}
},
fetchContext: async () => {
const [ services, error ] = await agent.service.list()
.then((result) => [ result ])
.catch((error) => [, error ])
error && 'do spana i zabic serwer'
const urls = Object.values(services)
.map(({ Address, Port }) => 'http://' + Address + ':' + Port)
return Promise.resolve(
Object.keys(services)
.reduce((prev, curr, index) => ({
...prev,
[curr]: {
src: urls[index]
}
}), {})
)
},
tracer
})
}