isValid = async (slug) => {
const proxyUrl = "https://nikita-sharov.herokuapp.com/";
const url = `${proxyUrl}https://stackshare.io/${slug}`;
const response = await fetch(url, {method: "HEAD"});
switch (response.status) {
case HttpStatus.OK:
return true;
case HttpStatus.NOT_FOUND:
return false;
case HttpStatus.TOO_MANY_REQUESTS:
throw "Request rate limiting by the proxy (Heroku)";
case HttpStatus.FORBIDDEN:
throw "IP blacklisting by the target (StackShare)";
default:
throw response.statusText;
}
}