| Total Complexity | 2 | 
| Complexity/F | 0 | 
| Lines of Code | 36 | 
| Function Count | 0 | 
| Duplicated Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | import { | ||
| 2 | applyMiddleware, | ||
| 3 | createStore, | ||
| 4 | AnyAction, | ||
| 5 | Store, | ||
| 6 | Dispatch, | ||
| 7 | } from "redux"; | ||
| 8 | import thunk, { ThunkDispatch } from "redux-thunk"; | ||
| 9 | import { composeWithDevTools } from "redux-devtools-extension"; | ||
| 10 | import { createLogger } from "redux-logger"; | ||
| 11 | import { apiMiddleware } from "redux-api-middleware"; | ||
| 12 | import rootReducer, { RootState } from "./store/store"; | ||
| 13 | |||
| 14 | /** Defining a dispatch for the app that accepts thunks */ | ||
| 15 | export type DispatchType = Dispatch<AnyAction, RootState> & | ||
| 16 | ThunkDispatch<any, any, AnyAction>; | ||
| 17 | |||
| 18 | export const configureStore = (): Store<RootState, AnyAction> => { | ||
| 19 | const logger = createLogger(); | ||
| 20 | |||
| 21 | const isDev = process.env.NODE_ENV === "development"; | ||
| 22 | |||
| 23 | let middleware = isDev | ||
| 24 | ? applyMiddleware(thunk, apiMiddleware, logger) | ||
| 25 | : applyMiddleware(thunk, apiMiddleware); | ||
| 26 | |||
| 27 |   if (isDev) { | ||
| 28 | middleware = composeWithDevTools(middleware); | ||
| 29 | } | ||
| 30 | |||
| 31 | const reducer = rootReducer(); | ||
| 32 | return createStore(reducer, middleware); | ||
| 33 | }; | ||
| 34 | |||
| 35 | export default configureStore; | ||
| 36 |