2017-03-03 17:21:07 +00:00
|
|
|
import Es6ObjectAssign from 'es6-object-assign';
|
|
|
|
import Es6Promise from 'es6-promise';
|
|
|
|
|
2017-01-27 15:05:44 +00:00
|
|
|
import { applyMiddleware, compose, createStore } from 'redux';
|
2016-09-07 00:04:02 +00:00
|
|
|
import { browserHistory } from 'react-router';
|
2017-01-27 15:05:44 +00:00
|
|
|
import { loadingBarMiddleware } from 'react-redux-loading-bar';
|
2016-09-07 00:04:02 +00:00
|
|
|
import { routerMiddleware } from 'react-router-redux';
|
2017-01-27 15:05:44 +00:00
|
|
|
import thunkMiddleware from 'redux-thunk';
|
2016-10-19 20:22:18 +00:00
|
|
|
|
2016-09-16 13:55:46 +00:00
|
|
|
import authMiddleware from './middlewares/auth';
|
2017-02-10 03:16:51 +00:00
|
|
|
import nagMessageMiddleware from './middlewares/nag_message';
|
2017-02-06 15:04:20 +00:00
|
|
|
import redirectMiddleware from './middlewares/redirect';
|
2016-09-07 00:04:02 +00:00
|
|
|
import reducers from './reducers';
|
|
|
|
|
2017-03-03 17:21:07 +00:00
|
|
|
// ie polyfills
|
|
|
|
Es6ObjectAssign.polyfill();
|
|
|
|
Es6Promise.polyfill();
|
|
|
|
|
2016-09-07 00:04:02 +00:00
|
|
|
const initialState = {};
|
2016-09-16 13:55:46 +00:00
|
|
|
|
|
|
|
const appliedMiddleware = applyMiddleware(
|
2016-09-07 00:04:02 +00:00
|
|
|
thunkMiddleware,
|
|
|
|
routerMiddleware(browserHistory),
|
2016-09-16 13:55:46 +00:00
|
|
|
authMiddleware,
|
2017-02-10 03:16:51 +00:00
|
|
|
nagMessageMiddleware,
|
2017-02-06 15:04:20 +00:00
|
|
|
redirectMiddleware,
|
2017-01-27 15:05:44 +00:00
|
|
|
loadingBarMiddleware({
|
|
|
|
promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAILURE'],
|
|
|
|
}),
|
2016-09-16 13:55:46 +00:00
|
|
|
);
|
2016-09-07 00:04:02 +00:00
|
|
|
|
2016-11-18 14:04:17 +00:00
|
|
|
const composeEnhancers = process.env.NODE_ENV !== 'production' &&
|
|
|
|
typeof global.window === 'object' &&
|
|
|
|
global.window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
|
|
|
|
global.window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : compose;
|
2016-09-07 00:04:02 +00:00
|
|
|
const store = createStore(
|
|
|
|
reducers,
|
|
|
|
initialState,
|
2016-11-18 14:04:17 +00:00
|
|
|
composeEnhancers(appliedMiddleware),
|
2016-09-07 00:04:02 +00:00
|
|
|
);
|
2016-09-16 13:55:46 +00:00
|
|
|
|
2016-09-07 00:04:02 +00:00
|
|
|
export default store;
|