Skip to content

Commit

Permalink
Build output for commit 405f0bc
Browse files Browse the repository at this point in the history
  • Loading branch information
thefakesujitk committed Dec 11, 2023
1 parent 405f0bc commit 4199d05
Showing 1 changed file with 14 additions and 29 deletions.
43 changes: 14 additions & 29 deletions dist/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const got_1 = __importDefault(require("got"));
const http_1 = __importDefault(require("http"));
const https_1 = __importDefault(require("https"));
const node_cache_1 = __importDefault(require("node-cache"));
const node_fetch_1 = __importDefault(require("node-fetch"));
const app = (0, express_1.default)();
const cache = new node_cache_1.default();
function createBadge(badge) {
Expand All @@ -26,15 +24,14 @@ function createBadge(badge) {
if (cache.has(url.toString())) {
return cache.get(url.toString());
}
const response = (yield (0, got_1.default)(url)).body;
cache.set(url.toString(), response);
return response;
const response = yield (0, node_fetch_1.default)(url);
const body = yield response.text();
cache.set(url.toString(), body);
return body;
});
}
app.use(express_1.default.static(__dirname + '/frontend/build', {
index: false
}));
app.get('/*', (req, res) => {
app.use(express_1.default.static(__dirname + '/frontend/build', { index: false }));
app.get('/*', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c, _d;
if (!("app" in req.query)) {
return res.status(200).sendFile(__dirname + '/frontend/build/index.html');
Expand Down Expand Up @@ -63,24 +60,12 @@ app.get('/*', (req, res) => {
}
else if (statusCode <= 399 && statusCode >= 300) {
}
res.setHeader('Content-type', 'image/svg+xml');
res.status(200).send(yield createBadge(badge));
createBadge(badge)
.then(badge => res.setHeader('Content-type', 'image/svg+xml').status(200).send(badge))
.catch(_ => res.status(500).send('Internal Server Error. Please open an issue at <a href="https://github.com/therealsujitk/vercel-badge/issues">vercel-badge/issues</a>.'));
});
try {
https_1.default.get("https://" + url, (response) => __awaiter(void 0, void 0, void 0, function* () {
var statusCode = response.statusCode;
yield handleRequest(statusCode);
})).on('error', () => {
http_1.default.get("http://" + url, (response) => __awaiter(void 0, void 0, void 0, function* () {
var statusCode = response.statusCode;
yield handleRequest(statusCode);
})).on('error', () => {
handleRequest(404);
});
});
}
catch (_e) {
res.status(500).send('Internal Server Error. Please open an issue at <a href="https://github.com/therealsujitk/vercel-badge/issues">vercel-badge/issues</a>.');
}
});
(0, node_fetch_1.default)(`http://${url}`)
.then(response => handleRequest(response.status))
.catch(_ => handleRequest());
}));
exports.default = app;

1 comment on commit 4199d05

@vercel
Copy link

@vercel vercel bot commented on 4199d05 Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.