Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
}),
// TODO: This has been moved over from `Utils/metaphysics` but can eventually
// be replaced by error / retry middleware
next => async req => {
const response = await next(req)
if (!checkStatus || (response.status >= 200 && response.status < 300)) {
return response
} else {
const error = new NetworkError(response.statusText)
error.response = response
throw error
}
},
loggingEnabled && loggerMiddleware(),
loggingEnabled && metaphysicsExtensionsLoggerMiddleware(),
loggingEnabled && errorMiddleware({ disableServerMiddlewareTip: true }),
])
const source = new RecordSource()
const store = new Store(source)
const environment = new Environment({
network,
store,
}) as RelaySSREnvironment
environment.relaySSRMiddleware = relaySSRMiddleware
return environment
}
export default function createEnvironment() {
const network = new RelayNetworkLayer([
cacheMiddleware(),
urlMiddleware({
url: metaphysicsURL,
headers: {
"Content-Type": "application/json",
"User-Agent": Emission.userAgent,
"X-USER-ID": Emission.userID,
"X-ACCESS-TOKEN": Emission.authenticationToken,
"X-TIMEZONE": Constants.LocalTimeZone,
},
}),
loggerMiddleware(),
errorMiddleware({
disableServerMiddlewareTip: true,
}),
metaphysicsExtensionsLoggerMiddleware(),
timingMiddleware(),
])
const source = new RecordSource()
const store = new Store(source)
return new Environment({
network,
store,
})
}