-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
42 lines (36 loc) · 1.04 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
exports.initialize = function( server ) {
server.error(function( err, req, res, next ){
if (err instanceof exports.NotFoundError) {
res.render( '404.jade', {
status: 404
} );
} else {
res.render( '500.jade', {
locals: {
error: err
}
, status: 500
} );
}
});
//A Route for Creating a 500 Error (Useful to keep around)
server.get( '/500', function( req, res ){
throw new Error( 'This is a 500 Error' );
} );
server.get( '/', function( req,res ) {
res.render( 'index.jade', {
locals : {
title: 'HackTG'
}
});
} );
//The 404 Route (ALWAYS Keep this as the last route)
server.get( '/*', function( req, res ){
throw new exports.NotFoundError;
} );
}
exports.NotFoundError = function( msg ) {
this.name = 'NotFound';
Error.call(this, msg);
Error.captureStackTrace(this, arguments.callee);
}