-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
51 lines (43 loc) · 1.11 KB
/
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
43
44
45
46
47
48
49
50
51
const express = require('express');
const nunjucks = require('nunjucks');
const routes = require('./routes');
const app = express();
const PORT = 3000;
app.use('/', routes);
app.use(express.static('public'));
app.set('view engine', 'html'); // have res.render work with html files
app.engine('html', nunjucks.render); // when giving html files to res.render, tell it to use nunjucks
nunjucks.configure('views', {
autoescape: true,
noCache: true
}); // point nunjucks to the proper directory for templates
//
// var locals = {å
// title: 'Favorite Characters',
// people: [
// { name: 'Gandalf'},
// { name: 'Frodo' },
// { name: 'Hermione'}
// ]
// };
// app.use('/', (req, res, next) => {
// const user = req.query.user;
// req.user = user;
// next();
// })
//
// app.use('/', (req, res, next) => {
// console.log('current user', req.user);
// next();
// })
app.use(function (req, res, next){
console.log(req.method, req.originalUrl);
next();
});
//
// app.get('/', (req,res) => {
// res.send("welcome, friend");
// });
app.listen(PORT, () => {
console.log("listening")}
);