-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (21 loc) · 687 Bytes
/
Copy pathserver.js
File metadata and controls
28 lines (21 loc) · 687 Bytes
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
const path = require('path');
const express = require('express');
const app = express();
let port = process.env.PORT;
if(port == null || port == "") {
port = 3000;
}
const routes = require('./routes/routes');
const errorController = require('./controllers/error');
// app.set('views', path.join(__dirname, 'public', 'dist'));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jsx');
// app.engine('jsx', require('express-react-views').createEngine());
// static path
const root = path.join(__dirname, 'public', 'dist');
const serve = express.static(root);
app.use(serve);
// routes
app.use(routes);
app.use(errorController.pageNotFound);
app.listen(port);