-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
31 lines (23 loc) · 798 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
//cmd line: npm run start
const express = require('express');
const app = express();
const cors = require('cors');
const { engine } = require('express-handlebars')
const pool = require('./creds');
// handlebars middleware
app.engine('hbs', engine({ extname: '.hbs', defaultLayout: 'main' }));
app.set('view engine', 'hbs');
// body parser middleware
app.use(cors());
app.use(express.json()); //req.body
app.use(express.urlencoded({ extended : false}))
// Set static folder
app.use(express.static('public'));
//ROUTES
app.get('/', (req,res) => res.render('index.html'))
app.use('/flight', require('./server/routes/flight'))
// set up the server listening at port 3000
const port = process.env.PORT || 3000;
app.listen(port, ()=>{
console.log(`Server has started on port ${port}`);
});