-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (25 loc) · 944 Bytes
/
app.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
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const path = require('path');
const cors = require('cors');
// Express Middleware (Body Parse, Static Files, View Engines)
// ===========================================================
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use(express.static( path.join(__dirname, 'client') ));
app.set('views', path.join(__dirname, 'server', 'views'));
app.set('view engine', 'ejs');
app.use(cors());
// Routes
// ===========================================================
const api = require('./server/routes/api');
const pages = require('./server/routes/pages');
app.use('/api', api);
app.use('/', pages);
// Listener
// ===========================================================
const PORT = process.env.PORT || 3000;
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});