Permalink
Browse files

Merge branch 'master' of https://github.com/thesentinelproject/threat…

  • Loading branch information...
jeromegv committed Sep 24, 2014
2 parents 7090fbc + 26c82f7 commit f49fd67cbbac6109f260ed1389c9ef401b06d9d0
Showing with 45 additions and 2 deletions.
  1. +4 −0 app.js
  2. +29 −2 routes.js
  3. +5 −0 views/404.jade
  4. +7 −0 views/500.jade
View
4 app.js
@@ -101,6 +101,10 @@ app.configure(function () {
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
// catch 404 errors
app.use(routes.notFound);
app.use(routes.serverError);
});
app.configure('development', function(){
View
@@ -30,7 +30,7 @@ function load_routes(app) {
exports.soc = function(req, res){
if((app.settings.env == 'development') ? (!authenticate(req, res)) : (authenticate(req, res))){
jquery.getJSON(host+'api/soc'+'?secretkey='+secretkey+'&callback=?', function(socs) {
//Render the page with list of SOCs only when we are done getting info about each datapoint
function render() {
@@ -85,7 +85,7 @@ function load_routes(app) {
exports.soc.edit = function(req, res){
if((app.settings.env == 'development') ? (!authenticate(req, res)) : (authenticate(req, res))){
var obj_id = req.query["id"];
jquery.getJSON(host+'api/soc/'+ obj_id +'?secretkey='+secretkey+'&callback=?', function(soc) {
soc.created = moment(soc.created).format("YYYY-MM-DD");
soc.modified = moment(soc.modified).format("YYYY-MM-DD");
@@ -409,4 +409,31 @@ function load_routes(app) {
}
}
exports.notFound = function(req, res){
res.status(404);
if(req.accepts('html')){
res.render('404', {title: '404: Not Found', url: req.url });
}
else if(req.accepts('json')){
res.json({ error: '404: Not Found' });
}
else{
res.send('404: Not Found');
}
};
exports.serverError = function(err, req, res, next){
err.status = err.status || 500;
res.status(err.status);
if(req.accepts('html')){
res.render('500', { title: 'Server Error', url: req.url, err: err });
}
else if(req.accepts('json')){
res.json({ error: err.status });
}
else{
res.send(err.status + ': Server Error');
}
};
exports.load_routes = load_routes;
View
@@ -0,0 +1,5 @@
extends layout
block pageContent
h3 404: Page Not Found
p You requested #{url}
View
@@ -0,0 +1,7 @@
extends layout
block pageContent
h3 HTTP Error from Server: #{err.status}
p You requested #{url}
strong Error Message
p #{err.toString()}

0 comments on commit f49fd67

Please sign in to comment.