-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserver.js
49 lines (39 loc) · 1.21 KB
/
server.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
var express = require('express');
var serveIndex = require('serve-index');
var ndjson = require('ndjson');
var concat = require('concat-stream');
var es = require('event-stream');
var bodyParser = require('body-parser');
var morgan = require('morgan');
var sMsa = require('./streamMsa');
var propMatchRegex = sMsa.propMatchRegex;
var getProteinSeqs = sMsa.getProteinSeqs;
var app = express();
app.use(bodyParser.urlencoded({extended: true}));
app.use(morgan('dev'));
// app.use('/data', serveIndex('data'));
// app.use('/data', express.static('data'));
app.use(express.static('public'));
// e.g. /aligned?q=mbp1
app.get('/aligned', [
function (req, res, next) {
req.opts = {
query: req.query.q,
vars: {
species: []
},
filters: [
function(obj) {
// e.g. /^mbp1.*\[.*\]$/i)
var regex = new RegExp('^' + req.query.q + '.*\\[.*\\]$', 'i');
return propMatchRegex(obj, 'title', regex);
}
],
uniqueSpecies: true
};
next();
},
getProteinSeqs
]);
app.listen(3000);
console.log('Express server listening on port 3000');