Public
Edited
Nov 30
20 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
topTrending = deploy(
"tweetTopTrending",
async (req, res, context) => {
const hasSent = (await db.child(contentHash).once("value")).val() !== null;
if (hasSent) return res.send("Already sent");
else {
try {
const response = await postWithImage(
"trendingnotebooks.bsky.social",
context.secrets["BLUESKY_TRENDING_APP_PASSWORD"],
imgBlob,
text
);
await db.child(contentHash).set(true);
return res.send(JSON.stringify(response));
} catch (err) {
return res.status(400).send(err.message);
}
}
},
{
modifiers: ["orchestrator"],
secrets: ["endpointservices_BLUESKY_TRENDING_APP_PASSWORD"]
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sendTweet = createTrigger({
name: "sendTweet",
authorized_public_keys: ["cg24TseUZnvEiO3XtXCFD08E9bX83Sv4rBHe2cjvpmU="],
// Serverside check, ensure only the current trending tweet is used
checkPayload: (payload) => payload.text === text && payload.img.startsWith("https://static.observableusercontent.com/thumbnail/"),
sample: {
text: text,
img: imgURL
}
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
postWithImage("trendingnotebooks.bsky.social", password, imgBlob, text)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
contentHash = hash(text)
Insert cell
contentHash.length
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more