-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (33 loc) · 1.21 KB
/
index.js
File metadata and controls
36 lines (33 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { compact } from 'lodash'
import { applyMiddleware, compose } from 'redux'
import { createLogger } from 'redux-logger'
import promiseMiddleware from 'redux-promise'
import { routerMiddleware } from 'connected-react-router'
import { isDev } from 'config'
import graphqlMiddleware from './graphqlMiddleware'
import apiMiddleware from './apiMiddleware'
import pendingMiddleware from './pendingMiddleware'
import optimisticMiddleware from './optimisticMiddleware'
import userBlockingMiddleware from './userBlockingMiddleware'
import mixpanelMiddleware from './mixpanelMiddleware'
import rollbarMiddleware from './rollbarMiddleware'
export default function createMiddleware (history, req) {
const middleware = compact([
routerMiddleware(history),
graphqlMiddleware,
apiMiddleware(req),
optimisticMiddleware,
pendingMiddleware,
promiseMiddleware,
userBlockingMiddleware,
mixpanelMiddleware,
rollbarMiddleware,
!req && isDev && createLogger({ collapsed: true })
])
const composeFn = typeof __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ !== 'undefined'
? __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ // eslint-disable-line no-undef
: compose
return composeFn(
applyMiddleware(...middleware)
)
}