forked from nodester/nodester
-
Notifications
You must be signed in to change notification settings - Fork 1
/
offline.js
64 lines (51 loc) · 1.34 KB
/
offline.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
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
/*
Nodester opensource Node.js hosting service
Written by: @_alejandromg
http://nodester.com
*/
var express = require('express')
, url = require('url')
, sys = require('sys')
, config = require('./config')
, middle = require('./lib/middle')
;
process.on('uncaughtException', function (err) {
console.log(new Date,'=> '+ err.message)
console.log(err.stack);
});
var app = express.createServer();
app.configure(function () {
app.use(express.bodyParser());
app.use(express.static(__dirname+'/public/images'));
app.use(express.errorHandler({
showStack: true,
dumpExceptions: true
}));
});
// Error handler
app.error(function (err, req, res, next) {
if (err instanceof NotFound) {
res.sendfile(__dirname + '/public/404.html');
} else {
res.sendfile(__dirname + '/public/500.html');
}
});
/* Routes */
app.all('*',function(req,res,next){
res.sendfile(__dirname+'/public/offline.html');
})
app.all('/images/*',function(req,res){
res.sendfile(__dirname+'/public/'+req.url);
})
app.get('/',function(req,res){
res.sendfile(__dirname+'/public/offline.html');
})
// Homepage
app.listen(4001);
console.log('Nodester mainteinance app started on port 4001');
function NotFound(msg) {
this.name = 'NotFound';
Error.call(this, msg);
Error.captureStackTrace(this, arguments.callee);
};