65 const { startDate, endDate } = getYesterdayDateRange();
66
67 const response = await fetch("https://api.linear.app/graphql", {
68 method: "POST",
69 headers: {
80
81 if (data.errors) {
82 console.error("Error fetching data from Linear API:", data.errors);
83 Deno.exit(1);
84 }
86 const issues = data.data.viewer.assignedIssues.nodes;
87
88 // Group issues by team and fetch issue history
89 const issuesByTeam: { [teamName: string]: any[] } = {};
90 for (const issue of issues) {
94 }
95
96 const historyResponse = await fetch("https://api.linear.app/graphql", {
97 method: "POST",
98 headers: {
110 if (historyData.errors) {
111 console.error(
112 `Error fetching history for issue ${issue.id}:`,
113 historyData.errors,
114 );
190 }
191
192 const slackResponse = await fetch("https://slack.com/api/chat.postMessage", {
193 method: "POST",
194 headers: {
65 const { startDate, endDate } = getYesterdayDateRange();
66
67 const response = await fetch("https://api.linear.app/graphql", {
68 method: "POST",
69 headers: {
80
81 if (data.errors) {
82 console.error("Error fetching data from Linear API:", data.errors);
83 Deno.exit(1);
84 }
86 const issues = data.data.viewer.assignedIssues.nodes;
87
88 // Group issues by team and fetch issue history
89 const issuesByTeam: { [teamName: string]: any[] } = {};
90 for (const issue of issues) {
94 }
95
96 const historyResponse = await fetch("https://api.linear.app/graphql", {
97 method: "POST",
98 headers: {
110 if (historyData.errors) {
111 console.error(
112 `Error fetching history for issue ${issue.id}:`,
113 historyData.errors,
114 );
190 }
191
192 const slackResponse = await fetch("https://slack.com/api/chat.postMessage", {
193 method: "POST",
194 headers: {
164 return generatedData;
165 } catch (error) {
166 console.error("Error fetching or processing data from OpenAI:", error);
167 console.warn("Using fallback race data due to the error.");
168 return fallbackRaceData.slice(0, numToRequest).map(race => ({
2
3export default async function handler() {
4 const response = await fetch("https://chadparker.com");
5 const body = await response.text();
6 const $ = cheerio.load(body);
36
37async function createTopic(): Promise<string> {
38 const res = await fetch(`${BASE}/topic`, { method: "POST", headers: AUTH_HDR });
39 if (!res.ok) throw new Error(`Mintlify /topic ${res.status}: ${await res.text()}`);
40 return (await res.json()).topicId;
42
43async function askMintlify(topicId: string, message: string): Promise<string> {
44 const res = await fetch(`${BASE}/message`, {
45 method: "POST",
46 headers: { "Content-Type": "application/json", ...AUTH_HDR },
95
96 /* Post nicely formatted message */
97 const slackRes = await fetch("https://slack.com/api/chat.postMessage", {
98 method: "POST",
99 headers: {
43 btn.disabled=true;
44 const q=encodeURIComponent(inp.value||"smiley face");
45 const r=await fetch("./draw?prompt="+q);
46 const {pegs}=await r.json();
47 ctx.fillStyle="#000";ctx.fillRect(0,0,cvs.width,cvs.height);
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
135 const lastSunday = today.startOf("week").minus({ days: 1 });
136
137 // Fetch relevant memories using the utility function
138 const memories = await getRelevantMemories();
139
67 const [currentPage, setCurrentPage] = useState(1);
68
69 const fetchMemories = useCallback(async () => {
70 setLoading(true);
71 setError(null);
72 try {
73 const response = await fetch(API_BASE);
74 if (!response.ok) {
75 throw new Error(`HTTP error! status: ${response.status}`);
78 setMemories(data);
79 } catch (e) {
80 console.error("Failed to fetch memories:", e);
81 setError(e.message || "Failed to fetch memories.");
82 } finally {
83 setLoading(false);
86
87 useEffect(() => {
88 fetchMemories();
89 }, [fetchMemories]);
90
91 const handleAddMemory = async (e: React.FormEvent) => {
100
101 try {
102 const response = await fetch(API_BASE, {
103 method: "POST",
104 headers: { "Content-Type": "application/json" },
112 setNewMemoryTags("");
113 setShowAddForm(false);
114 await fetchMemories();
115 } catch (e) {
116 console.error("Failed to add memory:", e);
123
124 try {
125 const response = await fetch(`${API_BASE}/${id}`, {
126 method: "DELETE",
127 });
129 throw new Error(`HTTP error! status: ${response.status}`);
130 }
131 await fetchMemories();
132 } catch (e) {
133 console.error("Failed to delete memory:", e);
155
156 try {
157 const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
158 method: "PUT",
159 headers: { "Content-Type": "application/json" },
164 }
165 setEditingMemory(null);
166 await fetchMemories();
167 } catch (e) {
168 console.error("Failed to update memory:", e);
135 ));
136
137// HTTP vals expect an exported "fetch handler"
138export default app.fetch;