2017-06-16 17:48:51 -07:00
|
|
|
var errorHandlers = require("../helpers/libraries/errorHandlers.js");
|
2017-06-16 19:31:31 -07:00
|
|
|
var showController = require("../controllers/showController.js");
|
2017-06-13 11:00:50 -07:00
|
|
|
|
2017-06-16 17:48:51 -07:00
|
|
|
module.exports = function(app, ua, googleAnalyticsId){
|
|
|
|
// route to fetch all free public claims
|
2017-06-13 11:00:50 -07:00
|
|
|
app.get("/:name/all", function(req, res){
|
2017-06-14 15:47:10 -07:00
|
|
|
console.log(">> GET request on /" + req.params.name + "/all");
|
2017-06-16 17:48:51 -07:00
|
|
|
// google analytics
|
2017-06-13 11:00:50 -07:00
|
|
|
ua(googleAnalyticsId, {https: true}).event("Show Routes", "/name/all", req.params.name + "/all").send();
|
2017-06-16 17:48:51 -07:00
|
|
|
// fetch all free public claims
|
|
|
|
showController.getAllClaims(req.params.name)
|
2017-06-13 11:00:50 -07:00
|
|
|
.then(function(orderedFreePublicClaims){
|
|
|
|
console.log("/:name/all success.");
|
|
|
|
res.status(200).render('allClaims', { claims: orderedFreePublicClaims });
|
|
|
|
return;
|
|
|
|
})
|
|
|
|
.catch(function(error){
|
|
|
|
console.log("/:name/all error:", error);
|
2017-06-16 17:48:51 -07:00
|
|
|
errorHandlers.handleRequestError(error, res);
|
2017-06-13 11:00:50 -07:00
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|