-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
50 lines (37 loc) · 1.34 KB
/
app.js
File metadata and controls
50 lines (37 loc) · 1.34 KB
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
/*
A simple drawing application for touch devices.
Loïc Fontaine - http://github.com/lfont - MIT Licensed
*/
var package = require('./package.json'),
express = require('express'),
routes = require('./routes');
var app = module.exports = express(),
appConfig = {
name: package.name,
version: package.version
};
// Configuration
app.configure(function () {
app.use(express.favicon(__dirname + '/public/img/icon-32.png'));
app.use(app.router);
});
app.configure('development', function () {
app.use(express.static(__dirname + '/public'));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
appConfig.environment = 'development';
});
app.configure('production', function () {
app.use(express.static(__dirname + '/public-build'));
app.use(express.errorHandler());
appConfig.environment = 'production';
});
express.static.mime.define({ 'application/x-web-app-manifest+json': [ 'webapp' ] });
express.static.mime.define({ 'text/cache-manifest': [ 'appcache' ] });
// Routes
app.get('/config.json', function (req, res) {
appConfig.installOrigin = appConfig.environment === 'production' ?
'http://webpaint.unfamous.org' :
'http://localhost:' + app.get('port');
res.send(appConfig);
});
routes.register(app);