index.js 572 字节
Newer Older
J
Jason Park 已提交
1 2 3 4 5 6
const compression = require('compression');
const history = require('connect-history-api-fallback');
const express = require('express');
const app = express();

const {
J
Jason Park 已提交
7
  apiEndpoint,
J
Jason Park 已提交
8 9 10
} = require('../environment');

const frontend = require('./frontend');
11
const backend = require('./backend');
J
Jason Park 已提交
12 13 14 15
app.use((req, res, next) => {
  if (req.hostname === 'algo-visualizer.jasonpark.me') return res.redirect(301, 'http://algorithm-visualizer.org/');
  next();
});
16
app.use(apiEndpoint, backend);
J
Jason Park 已提交
17 18 19 20
app.use(history());
app.use(compression());
app.use(frontend);

J
Jason Park 已提交
21
module.exports = app;