arxiv-sanityOverload / backend

1 stars 0 forks source link

change code #1

Open mr-woot opened 6 years ago

mr-woot commented 6 years ago

// import logger from "redux-logger";
import thunk from "redux-thunk";
import promiseMiddleware from "redux-promise-middleware";
import reduxReset from "redux-reset";

import reducer from "./reducers";

const middleware = applyMiddleware(promiseMiddleware(), thunk);
// const middleware = applyMiddleware(promiseMiddleware(), thunk, logger);

export default createStore(reducer,
    window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
    middleware,
    reduxReset());
mr-woot commented 6 years ago

import logger from "redux-logger";
import thunk from "redux-thunk";
import promiseMiddleware from "redux-promise-middleware";

import reducer from "./reducers";

// const middleware = applyMiddleware(promiseMiddleware(), thunk);
const middleware = applyMiddleware(promiseMiddleware(), thunk, logger);

export default createStore(reducer,
    middleware);
mr-woot commented 6 years ago
const bugsnagClient = bugsnag({
  apiKey: process.env.BUGSNAG_API_KEY,
  beforeSend: function(report) {
    if (
      report.errorMessage === "Request failed with status code 401" ||
      report.errorMessage === "Request failed with status code 403" ||
      report.errorMessage === "Request failed with status code 422" ||
      report.errorMessage === "Request failed with status code 502" ||
      report.errorMessage === "Request failed with status code 503"
    ) {
      report.ignore();
    }
    if (report.errorClass === "SyntaxError") {
      report.ignore();
    }
    if (
      process.env.NODE_ENV === "development" &&
      report.errorClass === "RangeError"
    ) {
      report.ignore();
    }
  }
});

import React from "react";
import ReactDOM from "react-dom";
import createPlugin from "bugsnag-react";

import { BrowserRouter } from "react-router-dom";
import { Provider } from "react-redux";
import axios from "axios";
import ScrollToTop from "./common/scroll_to_top";

import { LocaleProvider } from "antd";
import enUS from "antd/lib/locale-provider/en_US";

import Layout from "./layout";
import store from "./store";

import "antd/dist/antd.css";
import "./scss/styles.scss";
import { alert } from "./home/alert";
import { connect } from "react-redux";

// bugsnag({ autoCaptureSessions: false });
axios.defaults.withCredentials = true;

axios.interceptors.response.use(
  response => {
    return response;
  },
  error => {
    if (error.response && error.response.status === 503) {
      window.location.reload();
      return new Promise(() => {});
    }
    if (
      error.response &&
      error.response.status >= 500 &&
      error.response.status < 600
    ) {
      alert("Something unexpected occurred", "", "error");
    }
    return Promise.reject(error);
  }
);

const ErrorBoundary = bugsnagClient.use(createPlugin(React));
const app = document.getElementById("root");

ReactDOM.render(
  <Provider store={store}>
    <BrowserRouter>
      <ScrollToTop>
        <LocaleProvider locale={enUS}>
          <ErrorBoundary>
            <Layout />
          </ErrorBoundary>
        </LocaleProvider>
      </ScrollToTop>
    </BrowserRouter>
  </Provider>,
  app
);
prakritidev commented 6 years ago

@devilcrucifier Look into this