import express from "express"; import fetch from "node-fetch"; const app = express(); const BEARER = process.env.X_BEARER; let closures = []; async function pollX() { const query = encodeURIComponent( '(waffle house closed OR waffle house closure) -is:retweet' ); const res = await fetch( `https://api.twitter.com/2/tweets/search/recent?query=${query}&max_results=10`, { headers: { Authorization: `Bearer ${BEARER}` } } ); const json = await res.json(); if (!json.data) return; json.data.forEach(tweet => { closures.push({ state: "Unknown", city: "Unknown", location: tweet.text, reported: tweet.created_at }); }); } setInterval(pollX, 60000); app.get("/closures.json", (req, res) => { res.json(closures); }); app.listen(3000);