-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
51 lines (45 loc) · 1.68 KB
/
routes.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
// app/routes.js
/*
This is fairly straight forward. We are telling Express
that all routes will be sent to our public/index.html file.
This file will be our Ember application.
*/
var quotes = require('../api/quote');
module.exports = function(router) {
router.route('/quotes')
.post(function(req, res) {
quotes.addQuote(req,res);
})
.get(function(req,res) {
quotes.getAllQuotes(req,res);
//console.log(req.body);
});
/*
This tells Express to route quotes/quote_id on PUT requests to
updateQuote and DELETE requests to deleteQuote. The :quote_id is
a param added to the route retrieved from req.params. We pass
that same parameter to the module. V
*/
router.route('/quotes/:quote_id')
.get(function(req,res){
quotes.getAQuote(req,res,req.params.quote_id);
})
.put(function(req, res) {
quotes.updateQuote(req, res, req.params.quote_id);
})
.delete(function(req, res) {
quotes.deleteQuote(req, res, req.params.quote_id);
});
router.route('*').get(function(req, res) {
// load our public/index.html file// to use sendFile need to set root path
res.sendFile('/public/index.html', {root: '/home/ubuntu/workspace/meenserver/'});
});
};
/*
Oder router for making just a simple Node ember app
module.exports = function(app) {
app.get('*', function(req, res) {
res.sendfile('./public/index.html'); // load our public/index.html file
});
};
*/