39});
40
41// Export the fetch handler for Val Town
42export default liveReload(app.fetch, import.meta.url);
24 // Send a reply message
25 try {
26 await fetch(
27 `https://graph.facebook.com/v18.0/${business_phone_number_id}/messages`,
28 {
44
45 // Mark incoming message as read
46 await fetch(
47 `https://graph.facebook.com/v18.0/${business_phone_number_id}/messages`,
48 {
92});
93
94// Export app.fetch for Val Town, otherwise export app
95export default (typeof Deno !== "undefined" && Deno.env.get("valtown"))
96 ? app.fetch
97 : app;
11 const [error, setError] = useState(null);
12
13 const fetchData = async () => {
14 try {
15 const projectEndpoint = new URL(PROJECT_ENDPOINT, window.location.origin);
23 };
24
25 const { project } = await fetch(projectEndpoint, { headers })
26 .then(res => res.json());
27 const { files } = await fetch(filesEndpoint, { headers })
28 .then(res => res.json());
29
40 useEffect(() => {
41 if (!projectId) return;
42 fetchData();
43 }, [projectId, branchId]);
44
45 return { data, loading, error, refetch: fetchData };
46}
47
10 const [error, setError] = useState(null);
11
12 const fetchData = async () => {
13 try {
14 const res = await fetch(ENDPOINT, {
15 headers: {
16 "Authorization": "Bearer " + token,
18 })
19 const data = await res.json();
20 console.log("useProjects fetchData", { res, data });
21 if (!res.ok) {
22 console.error(data);
39
40 useEffect(() => {
41 fetchData();
42 }, []);
43
44 return { data, loading, error, refetch: fetchData };
45}
46
19 setError(null);
20 try {
21 const res = await fetch(ENDPOINT, {
22 method: "POST",
23 headers: {
16 setData(null);
17 setError(null);
18 const res = await fetch(ENDPOINT, {
19 method: "POST",
20 headers: {
9 const [loading, setLoading] = useState(true);
10
11 const fetchData = async () => {
12 const endpoint = new URL(ENDPOINT, window.location.origin);
13 endpoint.searchParams.append("projectId", projectId);
14
15 const res = await fetch(endpoint, {
16 headers: {
17 "Authorization": "Bearer " + token,
24 useEffect(() => {
25 if (!projectId) return;
26 fetchData();
27 }, [projectId]);
28
29 return { data, loading, refetch: fetchData };
30}
31
15 // replace all this with oauth when it's ready
16 try {
17 const res = await fetch("/api/user", {
18 headers: {
19 "Authorization": "Bearer " + valTownAPIKey,
59 // If we get here, authentication was successful
60
61 // Fetch all rows from the usage table
62 // Fetch all rows from the usage table
63 const allUsageData = await sqlite.execute(`SELECT * FROM ${USAGE_TABLE} ORDER BY timestamp DESC`);
64
65 // Fetch aggregated data grouped by user_id
66 const groupedUsageData = await sqlite.execute(`
67 SELECT
47<!--
48
49- [x] refetch project data on create/etc
50- [x] Loading favicon
51- [x] Ensure main branch is default selected