-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
42 lines (26 loc) · 922 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
32
33
34
35
36
37
38
39
40
41
42
const express = require('express');
const exphbs = require('express-handlebars');
const bodyParser = require('body-parser');
const path = require('path');
const app = express();
app.use(bodyParser.urlencoded({ extended: false}))
// Handlebars
app.engine('handlebars', exphbs({ defaultLayout: 'main'}));
app.set('view engine', 'handlebars');
// Setitng Static Folder
app.use(express.static(path.join( __dirname, 'public')));
//Database
const db = require('./config/database')
//Test Database
db.authenticate()
.then((data) => console.log(`Database Connected... ${{data}}`))
.catch((err) => console.log(`here is the error: ${err}`)
);
//Index Route
app.get('/', (req, res) => res.render('index', { layout: 'landing' }))
//Gigs routes
app.use('/gigs', require('./routes/gigs'))
const PORT = process.env.PORT || 5001
app.listen(PORT, () => {
console.log(`Server started on port ${PORT}`);
});