-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
22 lines (15 loc) · 957 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
const express = require('express') // import express
const app = express(); // instantiate express
const static = express.static(__dirname + '/public') // serve static assets -> css, client-side javascript, images served/stored from public directory
const configRoutes = require('./routes') // configure routes
const exphbs = require('express-handlebars') // import express handlebars
app.use('/public', static) // use the public directory as the static -> map lh3000/public
app.use(express.json()); // use express json
app.use(express.urlencoded({ extended:true })); // middleware fn for urlencoded to get form data
app.engine('handlebars', exphbs.engine({ defaultLayout: 'main' })); // set main layout
app.set('view engine', 'handlebars'); // view engine to handlebars
configRoutes(app);
app.listen(process.env.PORT || 3000, () => {
console.log("We've got a server");
console.log("Your routes will be running on http://localhost:3000");
})