git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: 7565f0a3a2bb8400488b3acd6395b0306df1c5df

Files: 7565f0a3a2bb8400488b3acd6395b0306df1c5df / app / api.js

845 bytesRaw
1const bulk = require('bulk-require')
2import feathers from 'feathers'
3import hooks from 'feathers-hooks'
4import rest from 'feathers-rest'
5import bodyParser from 'body-parser'
6import { map, mapObjIndexed, reduce, toPairs } from 'ramda'
7
8const services = {
9 ...map(
10 (module) => module.service.default,
11 bulk(__dirname, '*/service.js')
12 ),
13 ...map(
14 (module) => module.services.map(m => m.default),
15 bulk(__dirname, '*/services/*.js')
16 )
17}
18
19export default function createServer (config) {
20 const app = feathers()
21 .configure(rest())
22 .configure(hooks())
23 .use(bodyParser.json())
24 .use(bodyParser.urlencoded({ extended: true }))
25
26 useAll(app, services)
27
28 return app
29}
30
31function useAll (app, services) {
32 return reduce((app, [name, service]) => {
33 return app.use(`/${name}`, service)
34 }, app, toPairs(services))
35}
36

Built with git-ssb-web