git ssb

1+

dinoworm ๐Ÿ› / catstack



Commit 83061f88db26bb624bef7833f89b2565ee2d4031

consistent http.createServer exports

Michael Williams committed on 1/9/2016, 5:15:25 AM
Parent: 72d3e314ca4f0200e1b54a89f6c5deec821c7638

Files changed

api.jschanged
app/api.jschanged
app/client.jschanged
app/render.jschanged
app/static.jschanged
render.jschanged
static.jschanged
api.jsView
@@ -1,11 +1,11 @@
11 require('babel-core/register')
22
33 const config = require('app/config')
4-const createApi = require('app/api')
4+const createServer = require('app/api').createServer
55 const Url = require('url')
66
7-const server = createApi(config)
7+const server = createServer(config)
88
99 server.listen(config.api.url.port, function () {
1010 const apiUrl = Url.format(config.api.url)
1111 console.log(`api server listening at ${apiUrl}`)
app/api.jsView
@@ -1,14 +1,13 @@
11 const bulk = require('bulk-require')
2-import feathers from 'feathers'
2+import http from 'http'
3+import Server from 'feathers'
34 import hooks from 'feathers-hooks'
45 import rest from 'feathers-rest'
56 import bodyParser from 'body-parser'
67 import cors from 'cors'
78 import { map, mapObjIndexed, reduce, toPairs } from 'ramda'
89
9-import memory from 'feathers-memory'
10-
1110 const services = Object.assign(
1211 map(
1312 (module) => module.service.default,
1413 bulk(__dirname, '*/service.js')
@@ -18,21 +17,19 @@
1817 bulk(__dirname, '*/services/*.js')
1918 )
2019 )
2120
22-export default module.exports = createApi
23-
24-function createApi (config) {
25- const app = feathers()
21+export function createServer (config) {
22+ const server = Server()
2623 .use(cors())
2724 .configure(rest())
2825 .use(bodyParser.json())
2926 .use(bodyParser.urlencoded({ extended: true }))
3027 .configure(hooks())
3128
32- useAll(app, services)
29+ useAll(server, services)
3330
34- return app
31+ return http.createServer(server)
3532 }
3633
3734 function useAll (app, services) {
3835 return reduce((app, [name, service]) => {
app/client.jsView
@@ -1,11 +1,11 @@
1-import feathers from 'feathers-client'
1+import Client from 'feathers-client'
22 import fetch from 'isomorphic-fetch'
33 import Url from 'url'
44
55 import config from 'app/config'
66
7-const clientUrl = Url.format(config.api.url)
8-const client = feathers(clientUrl)
9- .configure(feathers.fetch(fetch))
7+const apiUrl = Url.format(config.api.url)
8+const client = Client(apiUrl)
9+ .configure(Client.fetch(fetch))
1010
1111 export default client
app/render.jsView
@@ -14,11 +14,9 @@
1414 import createStore from 'app/store'
1515 import routes from 'app/routes'
1616 import fetchAllData from 'app/util/fetch-all-data'
1717
18-export default module.exports = createRender
19-
20-function createRender (config) {
18+export function createServer (config) {
2119 const staticUrl = Url.format(config.static.url)
2220
2321 return http.createServer(render)
2422
@@ -44,9 +42,9 @@
4442 store.getState, store.dispatch,
4543 renderProps.location,
4644 renderProps.params
4745 ).then(function () {
48- const component = <Provider store={store} key="provider">
46+ const component = <Provider store={store}>
4947 <RoutingContext { ...renderProps } />
5048 </Provider>
5149
5250 var innerHtml
app/static.jsView
@@ -1,7 +1,7 @@
11 import http from 'http'
22
3-export default module.exports = function createStatic (config) {
3+export function createServer (config) {
44 const ecstatic = config.livereload ?
55 require('ecstatic-lr') : require('ecstatic')
66
77 return http.createServer(
render.jsView
@@ -1,12 +1,12 @@
11 require('babel-core/register')
22 require('css-modules-require-hook')
33
44 const config = require('app/config')
5-const createRender = require('app/render')
5+const createServer = require('app/render').createServer
66 const Url = require('url')
77
8-const server = createRender(config)
8+const server = createServer(config)
99
1010 server.listen(config.render.url.port, function () {
1111 const renderUrl = Url.format(config.render.url)
1212 console.log(`render server listening at ${renderUrl}`)
static.jsView
@@ -1,11 +1,11 @@
11 require('babel-core/register')
22
33 const config = require('app/config')
4-const createStatic = require('app/static')
4+const createServer = require('app/static').createServer
55 const Url = require('url')
66
7-const server = createStatic(config)
7+const server = createServer(config)
88
99 server.listen(config.static.url.port, function () {
1010 const staticUrl = Url.format(config.static.url)
1111 console.log(`static server listening at ${staticUrl}`)

Built with git-ssb-web