You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/image-url.jpg%20%22Optional%20title%22?q=fetch&page=13&format=json
For typeahead suggestions, use the /typeahead
endpoint:
https://codesearch.val.run/typeahead?q=fetch
Returns an array of strings in format "username" or "username/projectName"
Found 8301 results for "fetch"(421ms)
42const handleLogin = async (username, password) => {
43try {
44const response = await fetch("/login", {
45method: "POST",
46headers: { "Content-Type": "application/json" },
377}
378379if (path === "/fetch-news" && method === "GET") {
380const newsArticles = await sqlite.execute(`SELECT * FROM ${KEY}_news_articles ORDER BY created_at DESC`);
381return new Response(JSON.stringify({ articles: newsArticles.rows }), {
384}
385386if (path === "/fetch-media" && method === "GET") {
387const mediaEntries = await sqlite.execute(`SELECT * FROM ${KEY}_media_monitoring ORDER BY created_at DESC`);
388return new Response(JSON.stringify({ entries: mediaEntries.rows }), {
476477if (result.rowsAffected > 0) {
478// Fetch the updated article to return it to the client
479const updatedArticle = await sqlite.execute(`SELECT * FROM ${KEY}_news_articles WHERE id = ?`, [id]);
480487// This case should ideally not happen if rowsAffected > 0, but good for robustness
488return new Response(
489JSON.stringify({ success: false, message: "Article updated but could not be refetched" }),
490{
491status: 500, // Internal Server Error
538539if (result.rowsAffected > 0) {
540// Fetch the updated entry to return it
541const updatedEntry = await sqlite.execute(`SELECT * FROM ${KEY}_media_monitoring WHERE id = ?`, [id]);
542return new Response(JSON.stringify({ success: true, entry: updatedEntry.rows[0] }), {
573const sevenDaysAgoISO = sevenDaysAgo.toISOString(); // e.g., "2023-10-27T10:00:00.000Z"
574575// Fetch news article counts per author in the last 7 days
576const newsCountsResult = await sqlite.execute(
577`
584);
585586// Fetch media monitoring counts per author in the last 7 days
587const mediaCountsResult = await sqlite.execute(
588`
1import process from "node:process";
2import { BskyAgent } from "npm:@atproto/api";
3import fetch from "npm:node-fetch";
4import * as cheerio from "npm:cheerio";
5import fs from "node:fs";
31}
3233async function fetchWithRetry(url, options = {}, retries = 3, delay = 1000) {
34for (let i = 0; i < retries; i++) {
35try {
37const timeoutId = setTimeout(() => controller.abort(), 10000);
3839const response = await fetch(url, {
40...options,
41signal: controller.signal,
4950if (!response.ok) {
51throw new Error(`Failed to fetch: ${response.statusText}`);
52}
53return response;
54} catch (error) {
55if (i < retries - 1) {
56console.warn(`Fetch attempt ${i + 1} failed. Retrying...`);
57await new Promise(resolve => setTimeout(resolve, delay));
58} else {
63}
6465async function fetchNews() {
66const url = "https://glastonburyfestivals.co.uk/news/";
67try {
68const response = await fetchWithRetry(url);
69const html = await response.text();
70const $ = cheerio.load(html);
84return news;
85} catch (error) {
86console.error("Error fetching news:", error);
87throw error;
88}
9596const postedNewsTitles = loadPostedNews();
97const newsItems = await fetchNews();
98console.log(`Fetched ${newsItems.length} news items.`);
99100for (const news of newsItems) {