bsky_rss_pollmain.tsx1 match
3import { fetch } from "https://esm.town/v/std/fetch";
45export async function bsky_rss_poll() {
6const { parseFeed } = await import("https://deno.land/x/rss/mod.ts");
7const res = await fetch("https://v8.dev/blog.atom")
bsky_rss_pollREADME.md2 matches
4It's split into three parts:
51. [`bsky_rss_poll`](https://val.town/@jordan.bsky_rss_poll)
6- This function runs every hour and polls the provided RSS feed, turns it into XML and runs the check. If there *is* a new post, it tell `rss_to_bsky`to post a link (and the title) to Bluesky
72. [`latest_rss`](https://val.town/@jordan.latest_rss)
8- This is a stored object that keeps the latest object for the poll to test against
93. [`rss_to_bsky`](https://val.town/@jordan.rss_to_bsky)
10- This function turns the text post into a rich text post and posts it to Bluesky
1112Migrated from folder: Archive/bsky_rss_poll
extractValInfomain.tsx1 match
1export function extractValInfo(url: string | URL) {
2const { pathname, search } = new URL(url);
3const [author, filename] = pathname.split("/").slice(-2);
specialBlackMosquitomain.tsx3 matches
3import { createRoot } from "https://esm.sh/react-dom/client";
45function App() {
6return (
7<div>
11}
1213function client() {
14createRoot(document.getElementById("root")).render(<App />);
15}
16if (typeof document !== "undefined") { client(); }
1718export default async function server(request: Request): Promise<Response> {
19return new Response(`
20<html>
slackScoutmain.tsx10 matches
15}
1617export default async function(interval: Interval): Promise<void> {
18try {
19await createTable();
3839// Create an SQLite table
40async function createTable(): Promise<void> {
41await sqlite.execute(`
42CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
5051// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53return hackerNewsSearch({
54query: topic,
58}
5960async function fetchTwitterResults(topic: string): Promise<Website[]> {
61return twitterSearch({
62query: topic,
67}
6869async function fetchRedditResults(topic: string): Promise<Website[]> {
70return redditSearch({ query: topic });
71}
7273function formatSlackMessage(website: Website): string {
74const displayTitle = website.title || website.url;
75return `*<${website.url}|${displayTitle}>*
78}
7980async function sendSlackMessage(message: string): Promise<Response> {
81const slackWebhookUrl = Deno.env.get("SLACK_WEBHOOK_URL");
82if (!slackWebhookUrl) {
104}
105106async function isURLInTable(url: string): Promise<boolean> {
107const result = await sqlite.execute({
108sql: `SELECT 1 FROM ${TABLE_NAME} WHERE url = :url LIMIT 1`,
112}
113114async function addWebsiteToTable(website: Website): Promise<void> {
115await sqlite.execute({
116sql: `INSERT INTO ${TABLE_NAME} (source, url, title, date_published)
120}
121122async function processResults(results: Website[]): Promise<void> {
123for (const website of results) {
124if (!(await isURLInTable(website.url))) {
12* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
13* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
14* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
reqEvaltownmain.tsx4 matches
1import net, { AddressInfo } from "node:net";
23export default async function(req: Request): Promise<Response> {
4return serveRequest(
5req,
6`data:text/tsx,${
7encodeURIComponent(`
8export default async function(req: Request): Promise<Response> {
9return Response.json("I am within a worker!")
10}
14}
1516export async function serveRequest(req: Request, importUrl: string): Promise<Response> {
17let port = await getFreePort();
18const worker = new Worker(`https://esm.town/v/maxm/evaltownWorker?cachebust=${crypto.randomUUID()}`, {
56});
5758export async function isPortListening(port: number): Promise<boolean> {
59let isListening = false;
60const maxWaitTime = 2000; // ms
valtowntownmain.tsx5 matches
48await contentStore.init();
4950function Town() {
51return (
52<div
69}
7071function HomePage() {
72return (
73<html>
82<form method="POST" action="/submit">
83<textarea name="handler" rows={10} cols={50} autoFocus>
84{`export default async function(req: Request) {
85return Response.json("Hello, world!");
86}`}
95}
9697function ContentPage({ handler, id }: { handler: string; id: string }) {
98return (
99<html>
122let originalContent = textarea.value;
123124textarea.addEventListener('input', function() {
125if (textarea.value !== originalContent) {
126submitButton.style.display = 'inline-block';
graphqlAPIEndpointmain.tsx5 matches
15});
1617// Function to handle GraphQL requests
18async function handleGraphQLRequest(request: Request): Promise<Response> {
19const { query, variables } = await request.json();
2030}
3132// HTTP handler function
33export default altairClient(async function(req: Request): Promise<Response> {
34return handleGraphQLRequest(req);
35});
3637// Without the Altair GraphQL client:
38// export default async function(req: Request): Promise<Response> {
39// if (req.method === "POST") {
40// return handleGraphQLRequest(req);
altairClientmain.tsx2 matches
3import { getDistDirectory, renderAltair, RenderOptions } from "npm:altair-static";
45export function altairClient(next: (request: Request) => Response | Promise<Response>, options?: RenderOptions) {
6return async (request: Request) => {
7const { pathname } = new URL(request.url);
26}
2728export default altairClient(async function(request: Request): Promise<Response> {
29return new Response("Not found", { status: 404 });
30});