Files: 0a19ff71e90207bdc5e6b22d5470c11617f9f7b0 / app / server.js
593 bytesRaw
1 | const feathers = require('feathers') |
2 | const { mapObjIndexed, reduce, toPairs } = require('ramda') |
3 | |
4 | const serviceCreators = require('./services') |
5 | |
6 | module.exports = createServer |
7 | |
8 | const useAll = function (app, services) { |
9 | return reduce((app, [name, service]) => { |
10 | return app.use(`/${name}`, service) |
11 | }, app, toPairs(services)) |
12 | } |
13 | |
14 | function createServer (config) { |
15 | |
16 | const services = mapObjIndexed( |
17 | (serviceCreator, name) => { |
18 | return serviceCreator(config.services[name]) |
19 | }, |
20 | serviceCreators |
21 | ) |
22 | |
23 | const server = feathers() |
24 | |
25 | useAll(server, services) |
26 | |
27 | return server |
28 | } |
29 | |
30 |
Built with git-ssb-web