git ssb

1+

dinoworm ๐Ÿ› / catstack



Commit 0a19ff71e90207bdc5e6b22d5470c11617f9f7b0

boil the plates

Michael Williams committed on 11/28/2015, 8:43:07 AM
Parent: a911726b99b0e4c5da2f7dd6d4905059b64b9500

Files changed

app/client.jschanged
app/package.jsonchanged
app/server.jschanged
app/services/static.jschanged
app/containers/app.jsadded
app/containers/dev-tools.jsadded
app/containers/root.jsadded
app/containers/todo-list.jsadded
app/routes.jsadded
app/state.jsadded
app/store.jsadded
client.jschanged
package.jsonchanged
server.jschanged
app/client.jsView
@@ -1,26 +1,23 @@
11 const React = require('react')
22 const { render } = require('react-dom')
33 const { createStore, applyMiddleware } = require('redux')
4+import { reduxReactRouter, routerStateReducer, ReduxRouter } from 'redux-router';
45 const { Provider } = require('react-redux')
5-const logger = require('redux-logger')
66 const thunk = require('redux-thunk')
77
8-const reducer = require('./reducers')
9-const { getAllTodos } = require('./actions')
10-const App = require('./containers/App')
8+const createInitialState = require('app/state')
9+const configureStore = require('app/store')
10+const { getAllTodos } = require('app/actions')
11+const Root = require('app/containers/root')
1112
12-const middleware = process.env.NODE_ENV === 'production' ?
13- [ thunk ] :
14- [ thunk, logger() ]
13+const store = configureStore(
14+ createInitialState()
15+)
1516
16-const createStoreWithMiddleware = applyMiddleware(...middleware)(createStore)
17-const store = createStoreWithMiddleware(reducer)
17+//store.dispatch(getAllTodos())
1818
19-store.dispatch(getAllTodos())
19+const main = document.createElement('main')
2020
21-render(
22- <Provider store={store}>
23- <App />
24- </Provider>,
25- document.getElementById('root')
26-)
21+document.body.appendChild(main)
22+
23+render(<Root />, main)
app/package.jsonView
@@ -1,6 +1,15 @@
11 {
22 "browser": {
33 "./api.js": "./clients/index.js",
44 "./config.js": "./config-browser.js"
5+ },
6+ "browserify": {
7+ "transform": [
8+ "babelify",
9+ "envify",
10+ ["evalify", { "files": [ "config-browser.js" ] } ],
11+ "bulkify",
12+ "sheetify/transform"
13+ ]
514 }
615 }
app/server.jsView
@@ -1,11 +1,29 @@
11 const feathers = require('feathers')
2-const { mapObj, reduce } = require('ramda')
2+const { mapObjIndexed, reduce, toPairs } = require('ramda')
33
4-const createServices = require('./services')
4+const serviceCreators = require('./services')
55
6-function start (config) {
7- const services = mapObj(
8- (serviceCreator, name) => serveCreator(config[name]),
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+ },
920 serviceCreators
1021 )
22+
23+ const server = feathers()
24+
25+ useAll(server, services)
26+
27+ return server
1128 }
29+
app/services/static.jsView
@@ -1,5 +1,6 @@
11 const serveStatic = require('serve-static')
2+const { join } = require('path')
23
34 module.exports = createStaticService
45
56 function createStaticService (config) {
app/containers/app.jsView
@@ -1,0 +1,18 @@
1+const React = require('react')
2+const { connect } = require('react-redux')
3+
4+class App extends React.Component {
5+ render () {
6+ const { children } = this.props
7+
8+ return <div>
9+ <span>hello world!</span>
10+ { children }
11+ </div>
12+ }
13+}
14+
15+module.exports = connect(
16+ App,
17+ (state) => { return {} }
18+)
app/containers/dev-tools.jsView
@@ -1,0 +1,14 @@
1+const React = require('react')
2+const { createDevTools } = require('redux-devtools')
3+const LogMonitor = require('redux-devtools-log-monitor')
4+const DockMonitor = require('redux-devtools-dock-monitor')
5+
6+const DevTools = createDevTools(
7+ <DockMonitor toggleVisibilityKey='H'
8+ changePositionKey='Q'>
9+ <LogMonitor />
10+ </DockMonitor>
11+)
12+
13+module.exports = DevTools
14+
app/containers/root.jsView
@@ -1,0 +1,29 @@
1+const React = require('react')
2+const { Provider } = require('react-redux')
3+const { ReduxRouter } = require('redux-router')
4+
5+const routes = require('app/routes')
6+
7+if (process.env.NODE_ENV === 'development') {
8+ const DevTools = require('app/containers/dev-tools')
9+}
10+
11+class Root extends React.Component {
12+ render() {
13+ const { store } = this.props;
14+
15+ return (
16+ <Provider store={store}>
17+ <div>
18+ <ReduxRouter>
19+ { routes }
20+ </ReduxRouter>
21+ (process.env.NODE_ENV === 'development') ?
22+ <DevTools /> : null
23+ </div>
24+ </Provider>
25+ )
26+ }
27+}
28+
29+module.exports = Root
app/containers/todo-list.jsView
@@ -1,0 +1,15 @@
1+const React = require('react')
2+const { connect } = require('react-redux')
3+
4+class TodoList extends React.Component {
5+ render () {
6+ return <div>
7+ todo list!
8+ </div>
9+ }
10+}
11+
12+module.exports = connect(
13+ TodoList,
14+ (state) => { return {} }
15+)
app/routes.jsView
@@ -1,0 +1,12 @@
1+const { Route } = require('react-router')
2+
3+const App = require('app/containers/app')
4+const TodoList = require('app/containers/todo-list')
5+
6+const routes = (
7+ <Route path='/' component={App}>
8+ <Route path='todos' component={TodoList} />
9+ </Route>
10+)
11+
12+module.exports = routes
app/state.jsView
@@ -1,0 +1,9 @@
1+module.exports = createInitialState
2+
3+function createInitialState () {
4+ const initialState = {
5+ todos: {}
6+ }
7+
8+ return initialState
9+}
app/store.jsView
@@ -1,0 +1,59 @@
1+const { createStore, compose, applyMiddleware } = require('redux')
2+const thunk = require('redux-thunk')
3+const logger = require('redux-logger')
4+const { reduxReactRouter, routerStateReducer, ReduxRouter } = require('redux-router')
5+const { createHistory } = require('history')
6+
7+const rootReducer = require('app/reducers')
8+const routes = require('routes')
9+
10+let storesEnhancers = []
11+let middleware = []
12+
13+middleware.push(thunk)
14+
15+if (process.env.NODE_ENV === 'development') {
16+ const { persistState } = require('redux-devtools')
17+
18+ middleware.push(logger())
19+}
20+
21+storesEnhancers.push(
22+ applyMiddleware(middleware)
23+)
24+
25+if (process.env.NODE_ENV === 'development') {
26+ storesEnhancers.push(DevTools.instrument())
27+ storesEnhancers.push(persistState(
28+ window.location.href.match(
29+ /[?&]debug_session=([^&]+)\b/
30+ )
31+ ))
32+}
33+
34+storesEnhancers.push(
35+ reduxReactRouter({
36+ routes, createHistory
37+ })
38+)
39+
40+const finalCreateStore = compose(
41+ ...storesEnhancers
42+)(createStore)
43+
44+function configureStore(initialState) {
45+ const store = finalCreateStore(rootReducer, initialState)
46+
47+ if (process.env.NODE_ENV === 'development') {
48+ if (module.hot) {
49+ module.hot.accept('app/reducers', () =>
50+ store.replaceReducer(require('app/reducers'))
51+ )
52+ }
53+ }
54+
55+ return store
56+}
57+
58+module.exports = configureStore
59+
client.jsView
@@ -1,1 +1,1 @@
1-require('./app/client')
1+require('app/client')
package.jsonView
@@ -9,21 +9,15 @@
99 "format": "snazzy --format",
1010 "test": "(npm run spec & npm run feature)",
1111 "spec": "node spec",
1212 "feature": "node feature",
13- "dev:client": "budo client --dir assets --serve bundle.js --live -- -d",
13+ "dev:client": "watchify client -o assets/bundle.js -dv -p browserify-hmr",
1414 "dev:server": "nodemon server",
1515 "prod:client": "browserify client -o assets/bundle.js -g uglifyify",
1616 "prod:server": "node server",
17- "dev": "npm-run-all -p dev:*",
18- "prod": "npm-run-all -s prod:*"
17+ "dev": "NODE_ENV=development npm-run-all -p dev:*",
18+ "prod": "NODE_ENV=production npm-run-all -s prod:*"
1919 },
20- "browserify": {
21- "transform": [
22- "babelify",
23- "sheetify/transform"
24- ]
25- },
2620 "repository": {
2721 "type": "git",
2822 "url": "git+https://github.com/ahdinosaur/production-todomvc.git"
2923 },
@@ -50,27 +44,43 @@
5044 "node": "^4.0.0",
5145 "npm": "^3.0.0"
5246 },
5347 "devDependencies": {
48+ "browserify-hmr": "^0.3.1",
5449 "budo": "^6.1.0",
5550 "cuke-tap": "^1.0.2",
5651 "jsdom": "^7.1.0",
5752 "nodemon": "^1.8.1",
58- "tape": "^4.2.2"
53+ "redux-devtools": "^3.0.0-beta-3",
54+ "redux-devtools-dock-monitor": "^1.0.0-beta-3",
55+ "redux-devtools-log-monitor": "^1.0.0-beta-3",
56+ "redux-logger": "^2.0.4",
57+ "tape": "^4.2.2",
58+ "watchify": "^3.6.1"
5959 },
6060 "dependencies": {
6161 "babel-core": "^6.2.1",
6262 "babel-plugin-transform-object-rest-spread": "^6.1.18",
6363 "babel-preset-es2015": "^6.1.18",
6464 "babel-preset-react": "^6.1.18",
6565 "babelify": "^7.2.0",
66+ "browserify": "^12.0.1",
6667 "bulk-require": "^0.2.1",
6768 "bulkify": "^1.1.1",
69+ "envify": "^3.4.0",
6870 "evalify": "^1.0.1",
6971 "feathers": "^1.2.0",
72+ "history": "^1.13.1",
7073 "lnfs-cli": "^1.0.1",
7174 "npm-run-all": "^1.3.2",
7275 "ramda": "^0.18.0",
76+ "react": "^0.14.3",
77+ "react-dom": "^0.14.3",
78+ "react-redux": "^4.0.0",
79+ "react-router": "^1.0.0",
80+ "redux": "^3.0.4",
81+ "redux-router": "^1.0.0-beta4",
82+ "redux-thunk": "^1.0.0",
7383 "sheetify": "^3.1.0",
7484 "uglifyify": "^3.0.1"
7585 }
7686 }
server.jsView
@@ -1,2 +1,8 @@
11 require('babel-core/register')
2-require('./app/server')
2+
3+const createServer = require('app/server')
4+const config = require('app/config')
5+
6+const server = createServer(config)
7+
8+server.listen(process.env.PORT || 5000)

Built with git-ssb-web