1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { nominatimSearch } from "https://esm.town/v/stevekrouse/nominatimSearch";
4import { weatherGovGrid } from "https://esm.town/v/stevekrouse/weatherGovGrid";
14 lon,
15 });
16 let { properties: { periods } } = await fetchJSON(
17 grid.forecastHourly,
18 );
1import { latLngOfCity } from "https://esm.town/v/jdan/latLngOfCity";
2import { fetchWebpage } from "https://esm.town/v/jdan/fetchWebpage";
3import { weatherOfLatLon } from "https://esm.town/v/jdan/weatherOfLatLon";
4import { OpenAI } from "https://esm.town/v/std/openai?v=4";
59 call: weatherOfLatLon
60 },
61 "fetchWebpage": {
62 openAiTool: {
63 type: "function",
64 function: {
65 name: "fetchWebpage",
66 description: "Fetch the weather forecast from the contents of a forecast URL",
67 parameters: {
68 type: "object",
78 }
79 },
80 call: fetchWebpage
81 }
82};
15 const start = performance.now();
16 try {
17 res = await fetch(url);
18 end = performance.now();
19 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 }
18
19 const handleGenerate = async () => {
20 const response = await fetch("/generate", {
21 method: "POST",
22 headers: { "Content-Type": "application/json" },
19 const usernameInputRef = useRef(null);
20
21 const fetchMessages = useCallback(async () => {
22 try {
23 const response = await fetch("/messages");
24 const data = await response.json();
25 setMessages(data);
29 }
30 } catch (error) {
31 console.error("Failed to fetch messages:", error);
32 }
33 }, []);
34
35 const fetchJobs = useCallback(async () => {
36 try {
37 const response = await fetch("/jobs");
38 const data = await response.json();
39 setJobs(data);
40 } catch (error) {
41 console.error("Failed to fetch jobs:", error);
42 }
43 }, []);
44
45 useEffect(() => {
46 fetchMessages();
47 fetchJobs();
48
49 const messageInterval = setInterval(fetchMessages, 3000);
50 const jobInterval = setInterval(fetchJobs, 3000);
51 return () => {
52 clearInterval(messageInterval);
53 clearInterval(jobInterval);
54 };
55 }, [fetchMessages, fetchJobs]);
56
57 async function submitMessage(e) {
63
64 try {
65 const response = await fetch("/chat", {
66 method: "POST",
67 headers: { "Content-Type": "application/json" },
94
95 try {
96 const response = await fetch("/jobs", {
97 method: "POST",
98 headers: { "Content-Type": "application/json" },
31
32 try {
33 const response = await fetch(import.meta.url, {
34 method: "POST",
35 body: JSON.stringify({ campaignType, targetAudience }),
32export async function getSites(): Promise<Site[]> {
33 try {
34 const response = await fetch(`${API_ROOT}/sites.json`);
35 const parsedData = await response.json() as RegionsResponse;
36 return parsedData.Items;
92): Promise<Location[]> {
93 try {
94 const response = await fetch(`${API_ROOT}/locations/${siteId}.json`);
95 const parsedData = await response.json() as LocationsResponse;
96 return parsedData.Items;
21 if (hasRecordedAudio && mediaBlobUrl && !audioBase64) {
22 const processRecording = async () => {
23 // Fetch the blob from mediaBlobUrl
24 const response = await fetch(mediaBlobUrl);
25 const audioBlob = await response.blob();
26
13
14 useEffect(() => {
15 fetchJobPostings();
16 fetchChatMessages();
17 }, []);
18
19 const fetchJobPostings = async () => {
20 const response = await fetch("/job-postings");
21 const data = await response.json();
22 setJobPostings(data);
23 };
24
25 const fetchChatMessages = async () => {
26 const response = await fetch("/chat-messages");
27 const data = await response.json();
28 setChatMessages(data);
31 const submitJobPosting = async (e) => {
32 e.preventDefault();
33 await fetch("/job-postings", {
34 method: "POST",
35 headers: { "Content-Type": "application/json" },
38 setNewJobTitle("");
39 setNewJobDescription("");
40 fetchJobPostings();
41 };
42
47 return;
48 }
49 await fetch("/chat-messages", {
50 method: "POST",
51 headers: { "Content-Type": "application/json" },
56 });
57 setNewChatMessage("");
58 fetchChatMessages();
59 };
60
31 .get("/", (c) => c.redirect("/words"));
32
33export default app.fetch;
34