14## How It Works
15
161. When the "Generate Password" button is clicked, the app fetches a simple password from dinopass.com
172. It extracts two whole words from the response
183. It formats them as Word99Word! (with capitalized first letters)
163 } else {
164 // Use the server proxy
165 const response = await fetch("/api/process", {
166 method: "POST",
167 body: formData
727
728 try {
729 const response = await fetch("/api/detect-type", {
730 method: "POST",
731 headers: {
110}
111
112const useAuthenticatedFetch = () => {
113 const { getToken } = useAuth();
114
116 const token = await getToken();
117
118 return await fetch(`https://www.thegluechat.com${endpoint}`, {
119 method: "POST",
120 body: JSON.stringify(data),
813 setIsLoading(true);
814 // Reverse geocode the coordinates to get an address
815 const response = await fetch(
816 `https://maps.googleapis.com/maps/api/geocode/json?latlng=${position.coords.latitude},${position.coords.longitude}&key=AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U`,
817 );
1230});
1231
1232export default app.fetch;
65
66// This is the entry point for HTTP vals
67export default app.fetch;
22 const [isAddingInteraction, setIsAddingInteraction] = useState(false);
23
24 // Fetch interactions for this contact
25 const fetchInteractions = async () => {
26 if (!contact.id) return;
27
30
31 try {
32 const response = await fetch(`/api/contacts/${contact.id}/interactions`);
33 const result = await response.json();
34
35 if (!result.success) {
36 throw new Error(result.error || "Failed to fetch interactions");
37 }
38
40 } catch (err) {
41 setError(err instanceof Error ? err.message : "An unknown error occurred");
42 console.error("Error fetching interactions:", err);
43 } finally {
44 setIsLoading(false);
48 // Load interactions when contact changes
49 useEffect(() => {
50 fetchInteractions();
51 }, [contact.id]);
52
54 const handleAddInteraction = async (interaction: Interaction) => {
55 try {
56 const response = await fetch("/api/interactions", {
57 method: "POST",
58 headers: { "Content-Type": "application/json" },
69 }
70
71 fetchInteractions();
72 setIsAddingInteraction(false);
73 onContactUpdated();
83
84 try {
85 const response = await fetch(`/api/interactions/${id}`, {
86 method: "DELETE"
87 });
93 }
94
95 fetchInteractions();
96 onContactUpdated();
97 } catch (err) {
15 const [searchQuery, setSearchQuery] = useState("");
16
17 // Fetch contacts
18 const fetchContacts = async (query = "") => {
19 setIsLoading(true);
20 setError(null);
24 : "/api/contacts";
25
26 const response = await fetch(url);
27 const result = await response.json();
28
29 if (!result.success) {
30 throw new Error(result.error || "Failed to fetch contacts");
31 }
32
34 } catch (err) {
35 setError(err instanceof Error ? err.message : "An unknown error occurred");
36 console.error("Error fetching contacts:", err);
37 } finally {
38 setIsLoading(false);
42 // Initial load
43 useEffect(() => {
44 fetchContacts();
45 }, []);
46
48 useEffect(() => {
49 const delayDebounceFn = setTimeout(() => {
50 fetchContacts(searchQuery);
51 }, 300);
52
64 const handleAddContact = async (contact: Contact) => {
65 try {
66 const response = await fetch("/api/contacts", {
67 method: "POST",
68 headers: { "Content-Type": "application/json" },
76 }
77
78 fetchContacts();
79 setIsAddingContact(false);
80 } catch (err) {
89
90 try {
91 const response = await fetch(`/api/contacts/${contact.id}`, {
92 method: "PUT",
93 headers: { "Content-Type": "application/json" },
101 }
102
103 fetchContacts();
104 setSelectedContact({ ...contact });
105 setIsEditingContact(false);
115
116 try {
117 const response = await fetch(`/api/contacts/${id}`, {
118 method: "DELETE"
119 });
125 }
126
127 fetchContacts();
128 setSelectedContact(null);
129 } catch (err) {
232 onDelete={() => handleDeleteContact(selectedContact.id!)}
233 onContactUpdated={() => {
234 fetchContacts();
235 // Refresh the selected contact
236 if (selectedContact.id) {
237 fetch(`/api/contacts/${selectedContact.id}`)
238 .then(res => res.json())
239 .then(result => {
25 return c.json({ success: true, data: contacts });
26 } catch (error) {
27 console.error("Error fetching contacts:", error);
28 return c.json({ success: false, error: "Failed to fetch contacts" }, 500);
29 }
30});
41 return c.json({ success: true, data: contact });
42 } catch (error) {
43 console.error("Error fetching contact:", error);
44 return c.json({ success: false, error: "Failed to fetch contact" }, 500);
45 }
46});
108 return c.json({ success: true, data: interactions });
109 } catch (error) {
110 console.error("Error fetching interactions:", error);
111 return c.json({ success: false, error: "Failed to fetch interactions" }, 500);
112 }
113});
11 try {
12 const patchUrl = `${prUrl}.patch`;
13 const patchResponse = await fetch(patchUrl);
14 const patchContent = await patchResponse.text();
15
16 // Call AI service with your private API key
17 // Replace with your actual AI service URL
18 const aiResponse = await fetch("https://api.openai.com/v1/chat/completions", {
19 method: "POST",
20 headers: {
218
219// This is the entry point for HTTP vals
220export default app.fetch;
104 */
105 private async createCompletionViaProxy(params: any): Promise<any> {
106 const response = await fetch('/api/openai/chat', {
107 method: 'POST',
108 headers: {
124 */
125 private async createCompletionDirect(params: any): Promise<any> {
126 const response = await fetch(`${this.baseUrl}/chat/completions`, {
127 method: 'POST',
128 headers: {