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