-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
34 lines (29 loc) · 891 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
const figlet = require('figlet');
const express = require('express');
const app = express();
app.enable('trust proxy');
const title = figlet.textSync('FIGlet as a Service', { font: 'Doom' });
const info = `${title}\n`
+ ' Fetal-Neonatal Neuroimaging & Developmental Science Center\n'
+ " Boston Children's Hospital\n"
+ " and the Mass Open Cloud\n"
app.get('/', (req, res) => {
res.type('text/plain');
if (!req.query.message) {
res.status(400).send(
info + '\n\n' +
`usage: curl '${req.protocol}://${req.hostname}${req.path}?message=YOUR+TEXT'`
);
return;
}
figlet.text(req.query.message, {
font: 'Doom',
}, function(err, data) {
if (err) {
console.dir(err);
return;
}
res.status(200).send(data);
});
});
app.listen(process.env.PORT || 8080);