Skip to content

Commit

Permalink
[config] write config to serve prodution build from node server
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivekrajput20 committed Aug 17, 2019
1 parent f85fcf0 commit c5baf48
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
8 changes: 2 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@babel/register": "^7.5.5",
"autoprefixer": "^9.6.1",
"axios": "^0.19.0",
"compression": "^1.7.4",
"concurrently": "^4.1.1",
"cookie-parser": "^1.4.4",
"cookie-signature": "^1.1.0",
Expand Down
12 changes: 9 additions & 3 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import compression from "compression";
import cookieParser from "cookie-parser";
import express from "express";
import cookiesMiddleware from "universal-cookie-express";

import routes from "./routes";

const app = express();
const cookiesMiddleware = require("universal-cookie-express");
const path = require("path");

const app = express();
app.use(compression());
app.use(express.static(path.join(process.cwd(), "dist")));
app.use(cookieParser());
app.use(cookiesMiddleware());
app.use(express.json());
app.use(express.urlencoded({extended: false}));
app.use("/api/v1/:organization/account", routes.account);

app.get("*", function(req, res) {
res.sendFile(path.join(process.cwd(), "dist", "index.html"));
});
app.listen(3030, () => {
console.log("Server started on port 3030");
});

0 comments on commit c5baf48

Please sign in to comment.