12const FRED_API_KEY = process.env.FRED_API_KEY;
13
14// Function to fetch rate data from FRED API
15async function getRateData(seriesId: string): Promise<RateData> {
16 const url =
17 `https://api.stlouisfed.org/fred/series/observations?series_id=${seriesId}&api_key=${FRED_API_KEY}&file_type=json&sort_order=desc&limit=2`;
38}
39
40// Function to fetch all rate data
41async function getAllRateData(): Promise<RateData[]> {
42 const seriesIds = ["MORTGAGE30US", "SOFR30DAYAVG"];
43 const promises = seriesIds.map(seriesId => getRateData(seriesId));
45}
46
47// Function to format the email content
48function formatEmailContent(rateDataArray: RateData[]): string {
49 const rateRows = rateDataArray
50 .map(
77}
78
79// Main function to send the email
80export async function sendMortgageRateEmail() {
81 try {
82 const rateDataArray = await getAllRateData();
94}
95
96export default async function(interval: Interval) {
97 try {
98 const mortgageEmail = await sendMortgageRateEmail();
101 return { mortgageEmail: mortgageEmail };
102 } catch (error) {
103 console.error("Error in main function:", error);
104 throw error;
105 }
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [htmlInput, setHtmlInput] = useState("<h1>Hello, World!</h1>"); const [silliness, setSilliness] = useState(0);
8 const [slang, setSlang] = useState(0);
90}
91
92function client() {
93 createRoot(document.getElementById("root")).render(<App />);
94}
98}
99
100async function server(request: Request): Promise<Response> {
101 if (request.method === "POST" && new URL(request.url).pathname === "/api/modify") {
102 const { html, silliness, slang } = await request.json();
1import { versionLogger } from "https://esm.town/v/willthereader/versionLoggger";
2// version one is the one with the javascript scenario
3function App() {
4 let url = "";
5 let chapterTitles = "";
139}
140
141async function fetchThreadmarksFromServer(url, chapterTitles) {
142 const response = await fetch("/api/threadmarks", {
143 method: "POST",
154}
155
156async function getThreadmarkUrls(baseUrl, apiKey) {
157 versionLogger(import.meta.url);
158 const startTime = Date.now();
224}
225
226function parseThreadmarks(data) {
227 // console.log(`[INFO] Starting to parse threadmarks from HTML data. Total data length: ${data.length}`);
228 const threadmarks = [];
241}
242
243function compareThreadmarks(expectedTitles, retrievedThreadmarks) {
244 const expectedTitlesArray = expectedTitles.split("\n").map(title => title.trim()).filter(title => title !== "");
245 const retrievedTitles = retrievedThreadmarks.map(threadmark => threadmark.title);
298}
299
300function client() {
301 // console.log("Initializing client-side application");
302 const app = App();
308}
309
310export default async function server(request) {
311 console.log(`Received ${request.method} request for path: ${new URL(request.url).pathname}`);
312
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [query, setQuery] = useState("");
7 const [results, setResults] = useState([]);
63}
64
65function client() {
66 createRoot(document.getElementById("root")).render(<App />);
67}
69if (typeof document !== "undefined") { client(); }
70
71export default async function server(request: Request): Promise<Response> {
72 const url = new URL(request.url);
73
102 <script src="https://esm.town/v/std/catch"></script>
103 <script>
104 window.onerror = function(message, source, lineno, colno, error) {
105 console.error("Global error:", message, "at", source, ":", lineno, ":", colno);
106 if (error && error.stack) {
118}
119
120async function searchITunes(query: string) {
121 const url = `https://itunes.apple.com/search?term=${encodeURIComponent(query)}&entity=playlist&limit=20`;
122
1Helper function to call [SocialData](https://socialdata.tools) Twitter Search API, via my proxy: @stevekrouse/socialDataProxy
2
3Migrated from folder: social_data/socialDataSearch
5const url = new URL("https://api.socialdata.tools/twitter/search");
6
7export async function twitterAlert({ lastRunAt }: Interval) {
8 // search
9 const since = lastRunAt ? Math.floor(lastRunAt.getTime() / 1000) : 0;
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [messages, setMessages] = useState([]);
7 const [input, setInput] = useState("");
122}
123
124function client() {
125 createRoot(document.getElementById("root")).render(<App />);
126}
127if (typeof document !== "undefined") { client(); }
128
129export default async function server(request: Request): Promise<Response> {
130 const { OpenAI } = await import("https://esm.town/v/std/openai");
131 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1import { versionLogger } from "https://esm.town/v/willthereader/versionLoggger";
2
3function App() {
4 let url = "";
5 let chapterTitles = "";
139}
140
141async function fetchThreadmarksFromServer(url, chapterTitles) {
142 const response = await fetch("/api/threadmarks", {
143 method: "POST",
154}
155
156async function getThreadmarkUrls(baseUrl, apiKey) {
157 versionLogger(import.meta.url);
158 console.log(`[START] Threadmark URL fetch for base URL: ${baseUrl}`);
268}
269
270function parseThreadmarks(data) {
271 console.log(`[INFO] Starting to parse threadmarks from HTML data. Total data length: ${data.length}`);
272 const threadmarks = [];
285}
286
287function compareThreadmarks(expectedTitles, retrievedThreadmarks) {
288 const expectedTitlesArray = expectedTitles.split("\n").map(title => title.trim()).filter(title => title !== "");
289 const retrievedTitles = retrievedThreadmarks.map(threadmark => threadmark.title);
324}
325
326function client() {
327 console.log("Initializing client-side application");
328 const app = App();
334}
335
336export default async function server(request) {
337 console.log(`Received ${request.method} request for path: ${new URL(request.url).pathname}`);
338
1import { fetch } from "https://esm.town/v/std/fetch";
2
3async function fetchJSON(url: string) {
4 const response = await fetch(url);
5 if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
7}
8
9function roundTo(number: number, digits = 2) {
10 let multiplicatorString = "1";
11
20
21// View at https://wallek-currencyTransaction.val.run?target=gbp&root=eur&amount=100
22export default async function(req: Request): Promise<Response> {
23 const { rates } = await fetchJSON(`https://api.exchangerate-api.com/v4/latest/USD`);
24
4const tableName = Deno.env.get("AIRTABLE_TABLE_NAME");
5
6async function fetchAirtableData(uid: string) {
7 if (!airtableApiKey || !baseId || !tableName) {
8 throw new Error("Missing Airtable environment variables");
24}
25
26export default async function server(req: Request): Promise<Response> {
27 // Handle OPTIONS request for CORS preflight
28 if (req.method === "OPTIONS") {