Files: e077e8e4d717d2c79b41f7287c20906ac86841db / app / stack / index.js
652 bytesRaw
1 | const feathers = require('feathers') |
2 | const { mapObjIndexed, reduce, toPairs } = require('ramda') |
3 | |
4 | const stackCreators = { |
5 | services: require('./services'), |
6 | static: require('./static') |
7 | } |
8 | |
9 | module.exports = createStack |
10 | |
11 | function createStack(config) { |
12 | const stacks = createStacks(config) |
13 | |
14 | const app = feathers() |
15 | |
16 | useAll(app, stacks) |
17 | |
18 | return app |
19 | } |
20 | |
21 | function createStacks (config) { |
22 | return mapObjIndexed( |
23 | (stackCreator, name) => { |
24 | return stackCreator(config[name]) |
25 | }, |
26 | stackCreators |
27 | ) |
28 | } |
29 | |
30 | function useAll (app, services) { |
31 | return reduce((app, [name, service]) => { |
32 | return app.use(service) |
33 | }, app, toPairs(services)) |
34 | } |
35 | |
36 |
Built with git-ssb-web