forked from yathit/Aquaria
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
117 lines (96 loc) · 4.32 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* Module dependencies.
*/
var express = require('express');
var routes = require('./routes');
var http = require('http');
var path = require('path');
var fs = require('fs');
var shoe = require('shoe');
var dnode = require('dnode');
var autoComplete = require('./aquaria/autocomplete');
var secondary_clustering = require('./aquaria/secondary_clustering');
var metainfo = require('./aquaria/metainfo');
var viewer_format = require('./aquaria/generate_viewer_format');
var viewer = require('./aquaria/viewer');
var snapshot = require('./aquaria/snapshot');
var calculatePssh = require('./aquaria/calculatePssh');
var checkFasta = require('./aquaria/parseFasta');
var config = require('./common/config');
var JAR_EXPIRY = 1000 * 60 * 60 * 24 * 7;
var app = express();
// http://www.hacksparrow.com/express-js-logging-access-and-errors.html
var access_logfile = fs.createWriteStream('log/access.log', {flags: 'a'});
app.configure(function(){
app.set('port', process.env.PORT || config.app.port);
// Switched to EJS engine - see http://stackoverflow.com/questions/4600952/
// Info on EJS ('Embedded JavaScript templates') - https://github.com/visionmedia/ejs
app.set('view engine', 'ejs');
app.use(express.favicon(__dirname + '/public/images/favicon.ico'));
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public'), { maxAge: 3600000 }));
app.use('/jar', express.static(path.join(__dirname, 'jar'), { maxAge: JAR_EXPIRY}));
app.use(express.logger({stream: access_logfile }));
app.set('views', __dirname + '/views');
});
app.configure('production', function(){
app.use(express.errorHandler());
});
var server = http.createServer(app);
server.listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
var sock = shoe(function (stream) {
var d = dnode({
transform : function (s, cb) {
var res = s.replace(/[aeiou]{2,}/, 'oo').toUpperCase();
cb(res);
},
queryOrganism : autoComplete.queryOrganism,
queryProtein : autoComplete.queryProtein,
queryProteinWildOrganism: autoComplete.queryProteinWildOrganism,
queryPDB : autoComplete.queryPDB,
loadSnapshot : snapshot.loadSnapshot,
getJNLP : snapshot.getJNLP,
get_matching_structures : matching_structures.get_matching_structures,
getAccessionForPDB : matching_structures.getAccessionForPDBCallback,
get_secondary_clusters : secondary_clustering.get_secondary_clusters,
queryPDBTitle : secondary_clustering.queryPDBTitle,
get_3D_alignment : viewer_format.get_3D_alignment,
getPubMedForPDB : metainfo.getPubMedForPDB,
getOrganismInfo : metainfo.getOrganismInfo,
getProteinSynonyms : metainfo.getProteinSynonyms,
getOrganismSynonyms : metainfo.getOrganismSynonyms,
getOrganismName : metainfo.getOrganismName,
getChainInfo : metainfo.getChainInfo,
getOrganismId : metainfo.getOrganismId,
createAppJNLP : viewer.createJNLP,
createToolkitAppJNLP : viewer.createToolkitJNLP,
get_sequence : matching_structures.get_sequence,
checkFasta : checkFasta.checkFasta,
calculatePssh : calculatePssh.pssh
});
d.pipe(stream).pipe(d);
});
sock.install(server, '/dnode');
// Disable layout - http://stackoverflow.com/questions/4600952/
app.set('view options', {
layout: false
});
app.get('/user?', routes.sequenceInUrl);
app.get('/launch', routes.launchPage);
app.get('/googlehostedservice.html', routes.googleHostedService);
app.get('/jnlp/:versionString/:filename.jnlp', routes.jnlp);
app.get('/:id/cluster:clusterId.:format', routes.matchingStructuresExt);
app.get('/:id/:pdbid?/:chainid?.:format', routes.matchingStructuresExt);
app.get('/:id/:pdbid?/:chainid?', routes.home_page);
app.get('/', routes.home_page);
app.get('/robots.txt', function (req, res) {
res.type('text/plain');
res.send("User-agent: *\nDisallow:");
});