Skip to content

Commit 4f34e0d

Browse files
committed
Picking the correct sh file to send on URL query params
1 parent f80a3da commit 4f34e0d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

functions/index.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,30 @@ const storage = new Storage();
1010
const bucket = storage.bucket('installer-to.appspot.com');
1111

1212
app.get('/', (req, res) => {
13-
res.json({ status: 'OK' });
13+
res.set('Content-Type', 'application/json');
14+
res.json({ status: 'OK' });
15+
});
16+
17+
app.get('/health', (req, res) => {
18+
res.set('Content-Type', 'application/json');
19+
res.json({ status: 'OK' });
1420
});
1521

1622
app.get('/:package', (req, res) => {
1723
try {
18-
const file = bucket.file(req.params.package + '/installer.sh');
24+
const minParam = req.query.min;
25+
const withParam = req.query.with;
26+
const fileName = ['installer'];
27+
28+
if (minParam){
29+
fileName.push('min');
30+
}
31+
if (withParam){
32+
fileName.push(withParam);
33+
}
34+
fileName.push('sh');
35+
const fileNameString = fileName.join(".");
36+
const file = bucket.file(req.params.package + '/'+fileNameString);
1937
res.set('Content-Type', 'text/plain');
2038
const readStream = file.createReadStream();
2139
readStream.pipe(res);

0 commit comments

Comments
 (0)