BE App Versions for Shields.io
/**
* BE RUNKIT LAMBDA
* APP VERSIONS FOR SHIELDS.IO
*
* @author Eric L.
* @copyright 2020, BE
* @see https://www.its-be-studio.com
* @version 3.x
*/
module.exports.endpoint = function(req, res) {
res.setHeader("Content-Type", "application/json");
// Gets the `appName` from the URL whose version information is required.
const appName = req.url.substr(1);
// Fetch the versions JSON from BE.
const request = require("request");
let jsonObject;
const url = "https://www.its-be-studio.com/cdn/versions.json";
request(url, function(error, response, body) {
if (!error && response.statusCode === 200) {
jsonObject = JSON.parse(body);
// On successful retrieval of versions JSON sends response to use as endpoint at shields.io.
res.end(JSON.stringify({
schemaVersion: 1,
label: jsonObject[appName]["alias"],
message: jsonObject[appName]["version"],
color: jsonObject[appName]["colour"]
}));
}
});
}
no comments