git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: b0260714125b1a814ed76eaca838d164ae23101d

Files: b0260714125b1a814ed76eaca838d164ae23101d / app / api.js

956 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 cors from 'cors'
7import { map, mapObjIndexed, reduce, toPairs } from 'ramda'
8
9import memory from 'feathers-memory'
10
11const services = Object.assign(
12 map(
13 (module) => module.service.default,
14 bulk(__dirname, '*/service.js')
15 ),
16 map(
17 (module) => module.services.map(m => m.default),
18 bulk(__dirname, '*/services/*.js')
19 )
20)
21
22export default module.exports = createApi
23
24function createApi (config) {
25 const app = feathers()
26 .use(cors())
27 .configure(rest())
28 .use(bodyParser.json())
29 .use(bodyParser.urlencoded({ extended: true }))
30 .configure(hooks())
31
32 useAll(app, services)
33
34 return app
35}
36
37function useAll (app, services) {
38 return reduce((app, [name, service]) => {
39 return app.use(`/${name}`, service)
40 }, app, toPairs(services))
41}
42

Built with git-ssb-web