import { applyMiddleware, compose, createStore } from 'redux'
import { createHistory } from 'history'
import { syncHistory } from 'react-router-redux'
import thunk from 'redux-thunk'

import devToolsExtension from './devToolsExtension'
import reducer from 'reducers'

export const history = createHistory()

const reduxRouterMiddleware = syncHistory(history)

const store = createStore(reducer,
  compose(
    applyMiddleware(thunk, reduxRouterMiddleware),
    devToolsExtension
  )
)

if (module.hot) {
  module.hot.accept('../reducers', () => {
    const nextReducer =
      require('../reducers').default // eslint-disable-line global-require

    store.replaceReducer(nextReducer)
  })
}

reduxRouterMiddleware.listenForReplays(store)

export default store

@@ -140,24 +140,77 @@
 uter-redux'%0A
+import %7B apiMiddleware %7D from 'redux-api-middleware'%0A
 import thunk
@@ -500,16 +500,31 @@
 ddleware
+, apiMiddleware
 ),%0A    d

Include API middleware in the store