Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
chore: serve frontend from Express
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKohler committed Aug 15, 2020
1 parent 86c55c2 commit 498f12e
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 46 deletions.
2 changes: 1 addition & 1 deletion server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const votesRoutes = require('./routes/votes');

const app = express();

app.use(express.static(path.join(__dirname, 'public')));
app.use(cors());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json({ limit: '50mb' }));
Expand All @@ -20,5 +19,6 @@ app.use('/languages', languagesRoutes);
app.use('/sentences', sentencesRoutes);
app.use('/stats', statsRoutes);
app.use('/votes', votesRoutes);
app.use(express.static(path.resolve(__dirname, '..', 'web', 'dist')));

module.exports = app;
5 changes: 1 addition & 4 deletions web/src/backend.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { getBackendUrl } from './config';

export function sendRequest(endpoint, method = 'GET', data) {
const backendUrl = getBackendUrl();
const url = `${backendUrl}/${endpoint}`;
const url = `/${endpoint}`;
const options = {
method,
};
Expand Down
11 changes: 0 additions & 11 deletions web/src/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from 'react-router-dom';
import { ConnectedRouter } from 'connected-react-router';
import { getLanguages } from '../actions/languages';
import { login } from '../actions/login';

import Page from './page';
import Home from './pages/home';
Expand All @@ -23,16 +22,9 @@ class App extends React.Component {
super(props);

const {
username,
password,
login,
getLanguages,
} = props;

if (username && password) {
login(username, password);
}

getLanguages();
}

Expand Down Expand Up @@ -83,15 +75,12 @@ const PrivateRoute = (props) => {
function mapDispatchToProps(dispatch) {
return {
getLanguages: () => dispatch(getLanguages()),
login: (username, password) => dispatch(login(username, password)),
};
}

function mapStateToProps(state) {
return {
authed: state.login.authed,
username: state.login.username,
password: state.login.password,
};
}

Expand Down
2 changes: 0 additions & 2 deletions web/src/components/pages/rejected.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class Rejected extends React.Component {
render() {
const { rejectedSentences, loading } = this.state;

console.log(rejectedSentences, loading); // eslint-disable-line no-console

return (
<React.Fragment>
<h1>Your rejected sentences</h1>
Expand Down
6 changes: 2 additions & 4 deletions web/src/components/swipecard/DraggableCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DraggableCard extends Component {
startPosition: { x: 0, y: 0 }
});
}

panstart () {
const { x, y } = this.state;
this.setState({
Expand Down Expand Up @@ -70,7 +70,6 @@ class DraggableCard extends Component {
this.setState(this.calculatePosition( ev.deltaX, ev.deltaY ));
}
pancancel (ev) {
console.log(ev.type);
}

handlePan (ev) {
Expand All @@ -80,7 +79,6 @@ class DraggableCard extends Component {
}

handleSwipe (ev) {
console.log(ev.type);
}

calculatePosition (deltaX, deltaY) {
Expand All @@ -93,7 +91,7 @@ class DraggableCard extends Component {
componentDidMount () {
this.hammer = new Hammer.Manager(this.myRef.current.myRef.current);
this.hammer.add(new Hammer.Pan({ threshold: 2 }));

this.hammer.on('panstart panend pancancel panmove', this.handlePan);
this.hammer.on('swipestart swipeend swipecancel swipemove', this.handleSwipe);

Expand Down
22 changes: 0 additions & 22 deletions web/src/config.js

This file was deleted.

2 changes: 0 additions & 2 deletions web/src/reducers/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
export const INITIAL_STATE = {
authed: false,
username: null,
password: null,
loginDisabled: true,
errorMessage: null,
};
Expand Down Expand Up @@ -47,7 +46,6 @@ export default function(state = INITIAL_STATE, action) {
authed: true,
loginDisabled: false,
username: action.username,
password: action.password,
errorMessage: null,
});

Expand Down

0 comments on commit 498f12e

Please sign in to comment.