Commit 83061f88db26bb624bef7833f89b2565ee2d4031
consistent http.createServer exports
Michael Williams committed on 1/9/2016, 5:15:25 AMParent: 72d3e314ca4f0200e1b54a89f6c5deec821c7638
Files changed
api.js | changed |
app/api.js | changed |
app/client.js | changed |
app/render.js | changed |
app/static.js | changed |
render.js | changed |
static.js | changed |
api.js | ||
---|---|---|
@@ -1,11 +1,11 @@ | ||
1 | 1 | require('babel-core/register') |
2 | 2 | |
3 | 3 | const config = require('app/config') |
4 | -const createApi = require('app/api') | |
4 | +const createServer = require('app/api').createServer | |
5 | 5 | const Url = require('url') |
6 | 6 | |
7 | -const server = createApi(config) | |
7 | +const server = createServer(config) | |
8 | 8 | |
9 | 9 | server.listen(config.api.url.port, function () { |
10 | 10 | const apiUrl = Url.format(config.api.url) |
11 | 11 | console.log(`api server listening at ${apiUrl}`) |
app/api.js | ||
---|---|---|
@@ -1,14 +1,13 @@ | ||
1 | 1 | const bulk = require('bulk-require') |
2 | -import feathers from 'feathers' | |
2 | +import http from 'http' | |
3 | +import Server from 'feathers' | |
3 | 4 | import hooks from 'feathers-hooks' |
4 | 5 | import rest from 'feathers-rest' |
5 | 6 | import bodyParser from 'body-parser' |
6 | 7 | import cors from 'cors' |
7 | 8 | import { map, mapObjIndexed, reduce, toPairs } from 'ramda' |
8 | 9 | |
9 | -import memory from 'feathers-memory' | |
10 | - | |
11 | 10 | const services = Object.assign( |
12 | 11 | map( |
13 | 12 | (module) => module.service.default, |
14 | 13 | bulk(__dirname, '*/service.js') |
@@ -18,21 +17,19 @@ | ||
18 | 17 | bulk(__dirname, '*/services/*.js') |
19 | 18 | ) |
20 | 19 | ) |
21 | 20 | |
22 | -export default module.exports = createApi | |
23 | - | |
24 | -function createApi (config) { | |
25 | - const app = feathers() | |
21 | +export function createServer (config) { | |
22 | + const server = Server() | |
26 | 23 | .use(cors()) |
27 | 24 | .configure(rest()) |
28 | 25 | .use(bodyParser.json()) |
29 | 26 | .use(bodyParser.urlencoded({ extended: true })) |
30 | 27 | .configure(hooks()) |
31 | 28 | |
32 | - useAll(app, services) | |
29 | + useAll(server, services) | |
33 | 30 | |
34 | - return app | |
31 | + return http.createServer(server) | |
35 | 32 | } |
36 | 33 | |
37 | 34 | function useAll (app, services) { |
38 | 35 | return reduce((app, [name, service]) => { |
app/client.js | ||
---|---|---|
@@ -1,11 +1,11 @@ | ||
1 | -import feathers from 'feathers-client' | |
1 | +import Client from 'feathers-client' | |
2 | 2 | import fetch from 'isomorphic-fetch' |
3 | 3 | import Url from 'url' |
4 | 4 | |
5 | 5 | import config from 'app/config' |
6 | 6 | |
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)) | |
10 | 10 | |
11 | 11 | export default client |
app/render.js | ||
---|---|---|
@@ -14,11 +14,9 @@ | ||
14 | 14 | import createStore from 'app/store' |
15 | 15 | import routes from 'app/routes' |
16 | 16 | import fetchAllData from 'app/util/fetch-all-data' |
17 | 17 | |
18 | -export default module.exports = createRender | |
19 | - | |
20 | -function createRender (config) { | |
18 | +export function createServer (config) { | |
21 | 19 | const staticUrl = Url.format(config.static.url) |
22 | 20 | |
23 | 21 | return http.createServer(render) |
24 | 22 | |
@@ -44,9 +42,9 @@ | ||
44 | 42 | store.getState, store.dispatch, |
45 | 43 | renderProps.location, |
46 | 44 | renderProps.params |
47 | 45 | ).then(function () { |
48 | - const component = <Provider store={store} key="provider"> | |
46 | + const component = <Provider store={store}> | |
49 | 47 | <RoutingContext { ...renderProps } /> |
50 | 48 | </Provider> |
51 | 49 | |
52 | 50 | var innerHtml |
app/static.js | ||
---|---|---|
@@ -1,7 +1,7 @@ | ||
1 | 1 | import http from 'http' |
2 | 2 | |
3 | -export default module.exports = function createStatic (config) { | |
3 | +export function createServer (config) { | |
4 | 4 | const ecstatic = config.livereload ? |
5 | 5 | require('ecstatic-lr') : require('ecstatic') |
6 | 6 | |
7 | 7 | return http.createServer( |
render.js | ||
---|---|---|
@@ -1,12 +1,12 @@ | ||
1 | 1 | require('babel-core/register') |
2 | 2 | require('css-modules-require-hook') |
3 | 3 | |
4 | 4 | const config = require('app/config') |
5 | -const createRender = require('app/render') | |
5 | +const createServer = require('app/render').createServer | |
6 | 6 | const Url = require('url') |
7 | 7 | |
8 | -const server = createRender(config) | |
8 | +const server = createServer(config) | |
9 | 9 | |
10 | 10 | server.listen(config.render.url.port, function () { |
11 | 11 | const renderUrl = Url.format(config.render.url) |
12 | 12 | console.log(`render server listening at ${renderUrl}`) |
static.js | ||
---|---|---|
@@ -1,11 +1,11 @@ | ||
1 | 1 | require('babel-core/register') |
2 | 2 | |
3 | 3 | const config = require('app/config') |
4 | -const createStatic = require('app/static') | |
4 | +const createServer = require('app/static').createServer | |
5 | 5 | const Url = require('url') |
6 | 6 | |
7 | -const server = createStatic(config) | |
7 | +const server = createServer(config) | |
8 | 8 | |
9 | 9 | server.listen(config.static.url.port, function () { |
10 | 10 | const staticUrl = Url.format(config.static.url) |
11 | 11 | console.log(`static server listening at ${staticUrl}`) |
Built with git-ssb-web