forked from benedmunds/Node-Express-MVR-Example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.js
More file actions
48 lines (36 loc) · 896 Bytes
/
routes.js
File metadata and controls
48 lines (36 loc) · 896 Bytes
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
module.exports = function(app, models){
/**
* Index
*/
app.get('/', function(req, res){
if (app.requireAuth === true && req.loggedIn === false)
res.redirect('/auth/twitter');
//get all the examples
models.examples.find({}, function(err, docs){
//render the index page
res.render('index.jade', {
locals: {
title: 'Example',
examples: docs
}
});
});
});
/**
* View
*/
app.get('/view/:id', function(req, res){
if (app.requireAuth === true && req.loggedIn === false)
res.redirect('/auth/twitter');
//get the example
models.examples.findById(req.params.id, function(err, doc){
//render the view page
res.render('view.jade', {
locals: {
title: 'Example',
example: doc
}
});
});
});
};