-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
39 lines (33 loc) · 893 Bytes
/
index.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
const express = require('express');
const cors = require('cors');
const app = express();
const bodyParser = require('body-parser');
const clustalOmega = require('clustal-omega-wrapper');
const path = require('path');
clustalOmega.setCustomLocation(path.join(__dirname, './bin'));
app.use(cors());
app.use(bodyParser.json());
app.get('/', (req, res) => {
res.status(200).json({
version: 1.0,
api_working: true,
error: false
});
});
app.post('/align-sequence', (req, res) => {
if (!req.body.sequence) {
return res
.status(400)
.json({ error: true, message: 'No sequence sent!' })
}
clustalOmega.alignSeqString(req.body.sequence, 'fasta', (err, data) => {
if (err) {
res.status(400).json({ error: err });
} else {
res.status(200).json({ error: false, data: data });
}
});
});
app.listen(process.env.PORT || 3000, () => {
console.log('Server started!');
});