forked from revington/riot-express-todo-list
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
app.js
40 lines (32 loc) · 994 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
'use strict';
const express = require('express'),
api = require('./api'),
app = express(),
bodyParser = require('body-parser');
// Set the views directory and template engine
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
// Set our static directory for public assets like client scripts
app.use(express.static('public'));
// Parses the body on incoming requests
app.use(bodyParser.json());
// Pretty prints HTML output
app.locals.pretty = true;
// "/" route handler
app.get('/', function (req, res) {
res.render('index');
});
// tag route handler
app.get('/tags/:name.tag', function (req, res) {
var name = 'tag-' + req.params.name;
res.render('../client/' + name);
});
// Mount the api sub application
app.use('/api/todos/', api);
// Start listening for connections
app.listen(8080, function (err) {
if (err) {
console.error('Cannot listen at port 8080', err);
}
console.log('Todo app listening at port 8080');
});