-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
33 lines (21 loc) · 810 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
const express = require('express');
const app = express();
const hbs = require('express-handlebars');
const path = require('path');
// app.use lets us use any middleware application
app.use(express.json()); //this allows us to post raw json data when a post request is made
// serving static files
app.use(express.static(path.join(__dirname,'public')));
// connect MongoDB databsse
require('./server/database/database')();
// setup view engine
app.set('view engine','hbs');
app.engine('hbs',hbs.engine({
extname:'hbs',
defaultView:'default',
layoutsDir:path.join(__dirname,'views'),
partialsDir:path.join(__dirname,'views/partials')
}))
//calling routes
app.use('/',require('./server/router/router'));
app.listen(3000,()=>console.log(`Server is started on http://localhost:3000`));