Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(allTheThings): update to universal-redux npm module (react-router 2, redux-simple-router, babel 6) #759

Closed
wants to merge 75 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
09229a5
update paths to npm module
bdefore Nov 26, 2015
1cdb2ac
working with npm module
bdefore Nov 26, 2015
126dd9e
point to new external source
bdefore Nov 26, 2015
e6bbd1b
add static path
bdefore Nov 26, 2015
0ac38ef
update to unconfigured api
bdefore Nov 26, 2015
7d86dc5
fix npm lint
bdefore Nov 26, 2015
58acb59
update version
bdefore Nov 26, 2015
652263e
remove some dependencies that are now handled by redux-universal-test
bdefore Nov 26, 2015
c1623f1
return bootstrap config settings, no longer an issue
bdefore Nov 26, 2015
6a8d6e9
update to latest on npm
bdefore Nov 26, 2015
c72c33d
webpack is not needed by this repo anymore directly
bdefore Nov 26, 2015
f8afc25
remove some more unneeded deps
bdefore Nov 26, 2015
dde48b3
all of these are devDependencies now
bdefore Nov 26, 2015
e7c628f
not sure how the NODE_ENV got lost here
bdefore Nov 26, 2015
197522b
update to latest npm module
bdefore Nov 27, 2015
de1b8c4
forgot to put Home back in
bdefore Nov 27, 2015
e7f316a
update to new version of npm module, without example code in it
bdefore Nov 27, 2015
9e9fe66
use npm module bins instead
bdefore Nov 27, 2015
7e45218
update to latest npm module
bdefore Nov 27, 2015
a6dba3e
update to 0.4.0 of npm module which removes example api actions, we n…
bdefore Nov 27, 2015
86c8044
remove unrelated test, rename dep to redux-universal-starter
bdefore Nov 27, 2015
8449048
merge in master
bdefore Nov 27, 2015
798e7cc
update to newest npm module and fix karma tests
bdefore Nov 28, 2015
16815ee
remove obselete test-node configuration in travis
bdefore Nov 28, 2015
948b611
update to 0.11.0 which allows custom isomorphic tools configuration
bdefore Nov 29, 2015
9ac9218
update to latest
bdefore Nov 29, 2015
08483f1
trigger another travis build
bdefore Nov 29, 2015
0d1f7c5
fix linting errors from carried-over isomorphic tools config
bdefore Nov 29, 2015
916d1b9
verbose logging
bdefore Dec 1, 2015
ad1a3d5
pass correct bootstrap config on production, fix serverside renders n…
bdefore Dec 1, 2015
fa68c1a
update to latest npm module
bdefore Dec 1, 2015
fd2962f
update to new module name, add url-loader as it is a peer dependency …
bdefore Dec 1, 2015
2479a3d
update latest changes from react-redux-universal-hot-example repo
bdefore Dec 1, 2015
81435f1
merge in master
bdefore Dec 1, 2015
e5df1f5
remove old logs
bdefore Dec 1, 2015
c3fc59d
enable socket io
bdefore Dec 2, 2015
cf597ca
drop back to redux router beta4
bdefore Dec 2, 2015
ff34e08
bump npm module version
bdefore Dec 2, 2015
6059438
update to latest and provide npm script for easier development of uni…
bdefore Dec 2, 2015
5ac0d49
bump version, builds paths to reducers smarter
bdefore Dec 2, 2015
a7fcd08
update to latest npm module, add api to dev-universal script
bdefore Dec 3, 2015
73bc07a
update to new configuration structure
bdefore Dec 3, 2015
e52ed71
midway through removing need for config alias
bdefore Dec 3, 2015
3b7a78a
update to streamlined npm module config
bdefore Dec 3, 2015
7ee068e
move api back to example project
bdefore Dec 5, 2015
2901d26
add back test-node script to travis
bdefore Dec 5, 2015
b3f60fa
update to new npm module. ApiClient is now fetcher.js and a redux mid…
bdefore Dec 7, 2015
3ca5f0f
fixes build issue on deploys
bdefore Dec 7, 2015
462a309
missed dependency
bdefore Dec 7, 2015
012e864
explicitly require npm 3
bdefore Dec 7, 2015
4ea989d
revert previous and import properly in production
bdefore Dec 7, 2015
16f43aa
add socket io import
bdefore Dec 7, 2015
6d47993
support redux-simple-router
bdefore Dec 9, 2015
90f91f3
add some more deps that npm2 needs
bdefore Dec 10, 2015
b2c4b68
add another dep
bdefore Dec 10, 2015
8727c3c
merge in master
bdefore Dec 10, 2015
780e12d
fix tests
bdefore Dec 10, 2015
515c12f
remove test that depended on redux/create
bdefore Dec 10, 2015
413fc8d
trigger travis again after strange error installing deps
bdefore Dec 10, 2015
ede39fe
update previous references to redux-router
bdefore Dec 10, 2015
e14d9a9
cherry pick update f5f8e7b9955bca32a0715dd1c39c21c940100114 from exam…
bdefore Dec 14, 2015
93eaaf8
remove check for universal existence
bdefore Dec 14, 2015
83d01f0
remove object.assign
bdefore Dec 20, 2015
58e386e
update to beta3
bdefore Dec 20, 2015
021c2de
update to beta4
bdefore Dec 20, 2015
5634477
update to redux-simple-router 1.0.1 and universal-redux 1.0.0-beta5
bdefore Dec 20, 2015
fa01234
update to react-router 1.0.2 and universal-redux 1.0.0-beta6
bdefore Dec 20, 2015
08700ea
babel6 support via universal-redux
bdefore Dec 21, 2015
c2d217a
update to latest universal-redux
bdefore Dec 30, 2015
df82cc9
update to version of universal-redux that does not include bootstrap,…
bdefore Dec 30, 2015
3f63d17
update to latest universal-redux with react router 2 support
bdefore Dec 31, 2015
57e9431
update to 3.0
bdefore Dec 31, 2015
4c35f70
remove obselete configuration code, update to beta4
bdefore Jan 3, 2016
d0737c6
update to latest universal-redux, apiclient does not yet have access …
bdefore Jan 13, 2016
ad042ba
update to latest universal-redux, still not able to log in
bdefore Jan 16, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .babelrc

This file was deleted.

10 changes: 8 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ "extends": "eslint-config-airbnb",
{
"extends": "eslint-config-airbnb",
"env": {
"browser": true,
"node": true,
Expand Down Expand Up @@ -27,15 +28,20 @@
"settings": {
"import/parser": "babel-eslint",
"import/resolve": {
moduleDirectory: ["node_modules", "src"]
moduleDirectory: ["node_modules", "node_modules/universal-redux/node-modules", "src"]
}
},
"globals": {
"__DEVELOPMENT__": true,
"__CLIENT__": true,
"__SERVER__": true,
"__LOGGER__": false,
"__DISABLE_SSR__": true,
"__DEVTOOLS__": true,
"__META__": {},
"__API_ENDPOINT__": '',
"__API_HOST__": '',
"__API_PORT__": '',
"socket": true,
"webpackIsomorphicTools": true
}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist/
webpack-assets.json
webpack-stats.json
npm-debug.log
.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This is a starter boilerplate app I've put together using the following technolo
* [Webpack Hot Middleware](https://github.com/glenjamin/webpack-hot-middleware)
* [Redux](https://github.com/rackt/redux)'s futuristic [Flux](https://facebook.github.io/react/blog/2014/05/06/flux.html) implementation
* [Redux Dev Tools](https://github.com/gaearon/redux-devtools) for next generation DX (developer experience). Watch [Dan Abramov's talk](https://www.youtube.com/watch?v=xsSnOQynTHs).
* [Redux Router](https://github.com/rackt/redux-router) Keep your router state in your Redux store
* [Redux Simple Router](https://github.com/jlongster/redux-simple-router) Keep your router state in your Redux store
* [ESLint](http://eslint.org) to maintain a consistent code style
* [redux-form](https://github.com/erikras/redux-form) to manage form state in Redux
* [lru-memoize](https://github.com/erikras/lru-memoize) to speed up form validation
Expand Down
13 changes: 7 additions & 6 deletions api/api.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import express from 'express';
import session from 'express-session';
import bodyParser from 'body-parser';
import config from '../src/config';
import * as actions from './actions/index';
import {mapUrl} from 'utils/url.js';
import PrettyError from 'pretty-error';
import http from 'http';
import SocketIo from 'socket.io';

const apiPort = process.env.APIPORT;
const apiHost = process.env.APIHOST || 'localhost';

const pretty = new PrettyError();
const app = express();

Expand All @@ -24,7 +26,6 @@ app.use(session({
}));
app.use(bodyParser.json());


app.use((req, res) => {
const splittedUrlPath = req.url.split('?')[0].split('/').slice(1);

Expand Down Expand Up @@ -56,13 +57,13 @@ const bufferSize = 100;
const messageBuffer = new Array(bufferSize);
let messageIndex = 0;

if (config.apiPort) {
const runnable = app.listen(config.apiPort, (err) => {
if (apiPort) {
const runnable = app.listen(apiPort, (err) => {
if (err) {
console.error(err);
}
console.info('----\n==> 🌎 API is running on port %s', config.apiPort);
console.info('==> 💻 Send requests to http://%s:%s', config.apiHost, config.apiPort);
console.info('----\n==> 🌎 API is running on port %s', apiPort);
console.info('==> 💻 Send requests to http://%s:%s', apiHost, apiPort);
});

io.on('connection', (socket) => {
Expand Down
28 changes: 0 additions & 28 deletions bin/server.js

This file was deleted.

3 changes: 3 additions & 0 deletions bin/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
require('../server.babel'); // babel registration (runtime transpilation for node)
require('./start_es6.js');
60 changes: 60 additions & 0 deletions bin/start_es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env node
import path from 'path';
import http from 'http';
import { express, renderer } from 'universal-redux';
import httpProxy from 'http-proxy';
import config from '../config/universal-redux.config.js';
import SocketIo from 'socket.io';

const isProduction = process.env.NODE_ENV !== 'production';
const apiPort = process.env.APIPORT;
const apiHost = process.env.APIHOST || 'localhost';
const apiEndpoint = '/api';

function setupProxy(app) {

const proxy = httpProxy.createProxyServer({
target: 'http://' + apiHost + ':' + apiPort,
ws: true
});

// Proxy to API server
app.use(`${apiEndpoint}`, (req, res) => {
proxy.web(req, res);
});

// added the error handling to avoid https://github.com/nodejitsu/node-http-proxy/issues/527
proxy.on('error', (error, req, res) => {
let json;
if (error.code !== 'ECONNRESET') {
console.error('proxy error', error);
}
if (!res.headersSent) {
res.writeHead(500, {'content-type': 'application/json'});
}

json = {error: 'proxy_error', reason: error.message};
res.end(JSON.stringify(json));
});
}

const app = express(config);

setupProxy(app);

app.use(renderer(config));

const server = new http.Server(app);

if (!isProduction) {
const io = new SocketIo(server);
io.path(`${__API_ENDPOINT__}/ws`);
}

server.listen(config.server.port, (err) => {
if (err) {
console.error(err);
}
console.info('==> 🌎 API calls will be received at:', config.server.host + ':' + config.server.port + apiEndpoint);
console.info('==> 💻 Open http://localhost:%s in a browser to view the app.', config.server.port);
});
22 changes: 22 additions & 0 deletions config/meta.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
title: 'React Redux Example',
description: 'All the modern best practices in one example.',
meta: {
charSet: 'utf-8',
property: {
'og:site_name': 'React Redux Example',
'og:image': 'https://react-redux.herokuapp.com/logo.jpg',
'og:locale': 'en_US',
'og:title': 'React Redux Example',
'og:description': 'All the modern best practices in one example.',
'twitter:card': 'summary',
'twitter:site': '@erikras',
'twitter:creator': '@erikras',
'twitter:title': 'React Redux Example',
'twitter:description': 'All the modern best practices in one example.',
'twitter:image': 'https://react-redux.herokuapp.com/logo.jpg',
'twitter:image:width': '200',
'twitter:image:height': '200'
}
}
}
155 changes: 155 additions & 0 deletions config/universal-redux.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/* eslint-disable */
const path = require('path');
const isProduction = process.env.NODE_ENV === 'production';
const projectRoot = path.resolve(__dirname, '..');
const sourceRoot = path.resolve(__dirname, '../src');
const apiPort = process.env.APIPORT;
const apiHost = process.env.APIHOST || 'localhost';
const meta = require('./meta.config.js');

module.exports = {

/*
// Express configuration
*/
server: {
/*
// The host to run the Express universal renderer. See src/server.js.
//
// Expects: String
*/
host: process.env.HOST || 'localhost',

/*
// The port to run Express universal renderer will run on. See src/server.js.
//
// Expects: Number
*/
port: process.env.PORT,

/*
// The path at which static assets are served from. If omitted, Express will
// not serve any static assets. Optional.
//
// Expects: String
*/
staticPath: projectRoot + '/static',

/*
// The path at which a favicon image will be served from using the `serve-favicon`
// library. If omitted, Express will not serve a favicon. Optional.
//
// Expects: String
*/
favicon: projectRoot + '/static/favicon.ico'
},

/*
// Globals available to both serverside and clientside rendering.
// You may also add your own here.
*/
globals: {

/*
// Whether or not to run redux-logger
//
// Expects: Boolean
*/
__LOGGER__: false,

/*
// Whether or not to run redux-devtools
//
// Expects: Boolean
*/
__DEVTOOLS__: !isProduction,

__API_ENDPOINT__: '/api',
__API_PORT__: apiPort,
__API_HOST__: apiHost,
__META__: meta
},

/*
// Enable eslint checks per Webpack build. Will not be run
// on production.
//
// Expects: Boolean
*/
lint: {
enabled: false,
config: projectRoot + '/.eslintrc'
},

// babelConfig: projectRoot + '/.babelrc',

/*
// Enable native desktop notifications for Webpack build events.
// Will not be run on production.
//
// Expects: Boolean
*/
notifications: false,

/*
// Path to a file with customizations for the default
// webpack-isomorphic-tools configuration. Optional.
//
// Expects: String
*/
toolsConfigPath: __dirname + '/webpack-isomorphic-tools.config.js',

/*
// When eneabled, will output Webpack and Webpack Isomorphic
// Tools configurations at startup
//
// Expects: Boolean
*/
verbose: true,

/*
// The react-router Routes file, Required. Will be added to Webpack aliases.
*/
routes: sourceRoot + '/routes.js',

redux: {
/*
// A path to an index of middleware functions. Optional.
//
// Expects: String
*/
middleware: sourceRoot + '/redux/middleware/index.js'
},

/*
// The path to your replacement for the default HTML shell. Optional.
// If not provided, the default used will be that in src/helpers/Html.js.
// Will be added to Webpack aliases.
*/
// htmlShell: sourceRoot + '/helpers/Html.js',

webpack: {

/*
// Webpack configuration cusomtizations. There are more parameters
// available than specified here. For the full list, see
// https://webpack.github.io/docs/configuration.html.
*/
config: {

/*
// The Webpack devtool configuration. May affect build times.
// See https://webpack.github.io/docs/configuration.html#devtool
*/
devtool: 'inline-eval-cheap-source-map',

entry: {
main: [
'bootstrap-sass!' + sourceRoot + '/theme/bootstrap.config' + (isProduction ? '.prod' : '') + '.js',
'font-awesome-webpack!' + sourceRoot + '/theme/font-awesome.config' + (isProduction ? '.prod' : '') + '.js'
]
}
}
}
};
/* eslint-enable */
Loading