-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.js
42 lines (33 loc) · 1.17 KB
/
app.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
// This is the main TeenyUrl app module
require('mootools');
var express = require('express');
var path = require('path');
var app = express();
app.configure('development', function () {
app.use(express.logger('dev'));
});
app.configure(function() {
app.use(express.favicon(path.join(__dirname, '/public/img/favicon.ico')));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
app.configure('development', function() {
app.use(express.errorHandler());
});
require('./lib/DataAccessorFactory').build(function (err, dataAccessor) {
if (err) {
console.error(err);
process.exit(1);
}
require('./routes/api').register(app, dataAccessor);
require('./routes/redirect').register(app, dataAccessor);
// environment variable PORT will be defined when the app is
// running on Tempest cloud. The app must listen on this port otherwise
// the requests can't be routed.
var port = process.env.PORT || 3000;
app.listen(port, function() {
console.log("TeenyUrl is listening on port " + port);
});
});