Add serveMainPage action

This commit is contained in:
Michael Jackson 2018-07-10 07:03:53 +10:00
parent 8ef362ba09
commit 5b747dc48b
2 changed files with 14 additions and 11 deletions

View File

@ -0,0 +1,13 @@
const MainPage = require("../components/MainPage");
const renderPage = require("../utils/renderPage");
function serveMainPage(req, res) {
res.send(
renderPage(MainPage, {
scripts: req.bundle.getScripts("main"),
styles: req.bundle.getStyles("main")
})
);
}
module.exports = serveMainPage;

View File

@ -2,9 +2,6 @@ const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const MainPage = require("./components/MainPage");
const renderPage = require("./utils/renderPage");
function route(setup) {
const app = express.Router();
setup(app);
@ -14,14 +11,7 @@ function route(setup) {
function createRouter() {
const app = express.Router();
app.get("/", (req, res) => {
res.send(
renderPage(MainPage, {
scripts: req.bundle.getScripts("main"),
styles: req.bundle.getStyles("main")
})
);
});
app.get("/", require("./actions/serveMainPage"));
app.use(cors());
app.use(bodyParser.json());