let { twitterAPIDown } = await import("https://esm.town/v/stevekrouse/twitterAPIDown");
import process from "node:process";
import { msHour } from "https://esm.town/v/stevekrouse/msHour";
import { twitterSearch } from "https://esm.town/v/stevekrouse/twitterSearch";
export async function checkIfTwitterAPIIsDown() {
try {
const results = await twitterSearch({
query: '"hello"',
start_time: new Date(Date.now() - 1 * msHour),
bearerToken: process.env.twitter,
});
if (results.length) {
twitterAPIDown = {
down: false,
reason: `search returned ${results.length} results at ${new Date()}`,
};
} else {
twitterAPIDown = {
down: true,
reason: `search returned ${results.length} results at ${new Date()}`,
};
}
} catch (e) {
twitterAPIDown = {
down: false,
reason: `search errored ${e.message} at ${new Date()}`,
};
throw e;
}
}