@veecode-platform/safira-cli
Version:
Generate a microservice project from your spec.
49 lines (48 loc) • 1.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VkprRepositoryService = void 0;
const tslib_1 = require("tslib");
const https = tslib_1.__importStar(require("https"));
const properties = tslib_1.__importStar(require("../properties.json"));
const string_utils_1 = require("../utils/string-utils");
class VkprRepositoryService {
constructor() { }
async getReleaseLatest() {
return new Promise((resolve, reject) => {
const url = new URL(properties.vkpr["release-url"]);
const options = {
hostname: url.hostname,
port: 443,
path: url.pathname,
method: "GET",
headers: {
Accept: "application/vnd.github.v3+json",
"User-Agent": string_utils_1.StringUtils.getUserAgent(),
},
};
const req = https.request(options, res => {
res.setEncoding("utf8");
let body = "";
res.on("data", d => {
body += d;
});
res.on("end", () => {
if (res.statusCode === 200)
resolve(JSON.parse(body));
reject(new Error(`Error: ${res.statusCode}`));
});
});
req.on("error", error => {
reject(error);
});
req.end();
});
}
static get instance() {
if (!this._instance) {
this._instance = new this();
}
return this._instance;
}
}
exports.VkprRepositoryService = VkprRepositoryService;