ok maybe a little

This commit is contained in:
slonkazoid 2024-03-07 18:07:05 +03:00
parent a609dcef99
commit 501768a31d
Signed by: slonk
SSH key fingerprint: SHA256:tbZfJX4IOvZ0LGWOWu5Ijo8jfMPi78TU7x1VoEeCIjM

View file

@ -1,6 +1,7 @@
import express from "express"; import express from "express";
import logRequest from "./logger.js"; import logRequest from "./logger.js";
import { parse } from "node-html-parser"; import { parse } from "node-html-parser";
import { format } from "util";
const config = { const config = {
FUCKING_ENDPOINT: FUCKING_ENDPOINT:
@ -27,14 +28,18 @@ app.get("/*/status/*", async (req, res) => {
try { try {
twitter_res = await fetch(target); twitter_res = await fetch(target);
} catch (err) { } catch (err) {
returnres.status(502).send(err.message); return res
.status(502)
.send("Error from Twitter API: " + format("%s", err));
} }
if (twitter_res.status == 200) { if (twitter_res.status == 200) {
let body; let body;
try { try {
body = await twitter_res.json(); body = await twitter_res.json();
} catch (err) { } catch (err) {
return res.status(502).send(err.message); return res
.status(502)
.send("Error from Twitter API: " + format("%s", err));
} }
let html = parse(body.html); let html = parse(body.html);
let block = html.firstChild; let block = html.firstChild;