-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
33 lines (27 loc) · 856 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const history = require('connect-history-api-fallback');
const secure = require('express-force-https');
const contact = require('./src-server/routes/contact');
const sitemap = require('./src-server/routes/sitemap');
require('dotenv').config();
// Create HTTP server
const app = express();
const port = process.env.PORT || 5000;
app.listen(port);
// Middleware
app.use(secure);
app.use(cors({
origin: process.env.APP_HOST,
optionsSuccessStatus: 200,
}));
app.use(bodyParser.json());
app.use(history());
// Defining routes
app.use('/contact', contact);
app.use('/sitemap.xml', sitemap);
// Setting up static server
app.use(express.static(`${__dirname}/dist`));
// eslint-disable-next-line no-console
console.log(`Server started ${port}`);