2021-04-12 13:32:25 +00:00
|
|
|
import { applyMiddleware, compose, createStore } from "redux";
|
|
|
|
import { browserHistory } from "react-router";
|
|
|
|
import { routerMiddleware } from "react-router-redux";
|
|
|
|
import thunkMiddleware from "redux-thunk";
|
2016-10-19 20:22:18 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
import authMiddleware from "./middlewares/auth";
|
|
|
|
import redirectMiddleware from "./middlewares/redirect";
|
|
|
|
import reducers from "./reducers";
|
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,
|
2021-04-14 16:52:15 +00:00
|
|
|
redirectMiddleware
|
2016-09-16 13:55:46 +00:00
|
|
|
);
|
2016-09-07 00:04:02 +00:00
|
|
|
|
2021-04-12 13:32:25 +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,
|
2021-04-12 13:32:25 +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;
|