{"size": 787, "ext": "js", "max_stars_repo_path": "scripts/log.js", "max_stars_repo_name": "alecglassford/read.alec.casa", "max_stars_repo_stars_event_min_datetime": "2017-05-22T23:16:39.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-21T21:08:36.000Z", "max_issues_repo_path": "scripts/log.js", "max_issues_repo_name": "alecglassford/read.alec.casa", "max_issues_repo_issues_event_min_datetime": "2017-04-18T00:59:13.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-11T08:33:57.000Z", "max_forks_repo_path": "scripts/log.js", "max_forks_repo_name": "alecglassford/read.alec.casa", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 10, "max_forks_count": null, "avg_line_length": 24.59375, "max_line_length": 75, "alphanum_fraction": 0.6391359593}
#!/usr/bin/env deno

const decoder = new TextDecoder("utf-8");

const buildEndpoint = async function buildEndpoint() {
  const [secret] = Deno.args;
  const stdinBuf = await Deno.readAll(Deno.stdin);
  const [url, star] = decoder.decode(stdinBuf).split("***");
  const encodedUrl = encodeURIComponent(url);
  let endpoint =
    `https://alec-reads.glitch.me/read?secret=${secret}&url=${encodedUrl}`;
  if (star) {
    endpoint += "&star=%20";
    if (star !== "nocomment") {
      endpoint += encodeURIComponent(star);
    }
  }
  return endpoint;
};

const main = async function main() {
  const endpoint = await buildEndpoint();
  try {
    const res = await fetch(endpoint, { method: "POST" });
    console.log(res.statusText);
  } catch (err) {
    console.log(err);
  }
};

main();
