1export async function sendWebhookNotification(url: string, data: any) {
2 try {
3 const response = await fetch(url, {
4 method: 'POST',
5 headers: {
30
31 try {
32 const response = await fetch(
33 `${NOTION_DATABSE_API}/${COFFEE_TABLE_DB_ID}/query`,
34 {
66 if (beanRelation && beanRelation.length > 0) {
67 const beanId = beanRelation[0].id;
68 const beanResponse = await fetch(`${NOTION_PAGES_API}/${beanId}`, {
69 headers,
70 method: "GET",
389
390export function setCookie(key: string, value: string) {
391 fetch("/", {
392 method: "POST",
393 body: JSON.stringify({ cookie: { key, value } }),
389 const profileId = parseInt(params.get('profile') || '1', 10);
390
391 // Fetch profile data
392 const profileResult = await sqlite.execute(
393 `SELECT * FROM ${profileTable} WHERE id = ?`,
401 const profile = profileResult.rows[0];
402
403 // Fetch visit count for the profile
404 const visitsResult = await sqlite.execute(
405 `SELECT COUNT(*) as visit_count FROM ${visitsTable} WHERE profile_id = ?`,
409 const visitCount = visitsResult.rows[0]?.visit_count || 0;
410
411 // Fetch friends (for demo, just show some fake friends)
412 const demoFriends = [
413 { id: 2, display_name: "Chris" },
420 ];
421
422 // Fetch comments
423 const commentsResult = await sqlite.execute(
424 `SELECT c.*, p.display_name as author_name
34 "integrity": "sha512-OF8fFQSkbL7vJY9rfuegK1R7sPgQ6kFMkDamiEccNUvieQ+3urzfDFI616oPl8V7T9zRmnTkSjMOImYCAVRVuw==",
35 "dependencies": [
36 "@libsql/isomorphic-fetch",
37 "@libsql/isomorphic-ws",
38 "js-base64",
39 "node-fetch"
40 ]
41 },
42 "@libsql/isomorphic-fetch@0.3.1": {
43 "integrity": "sha512-6kK3SUK5Uu56zPq/Las620n5aS9xJq+jMBcNSOmjhNf/MUvdyji4vrMTqD7ptY7/4/CAVEAYDeotUz60LNQHtw=="
44 },
95 "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw=="
96 },
97 "fetch-blob@3.2.0": {
98 "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
99 "dependencies": [
105 "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
106 "dependencies": [
107 "fetch-blob"
108 ]
109 },
128 "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
129 },
130 "node-fetch@3.3.2": {
131 "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
132 "dependencies": [
133 "data-uri-to-buffer",
134 "fetch-blob",
135 "formdata-polyfill"
136 ]
44});
45
46// HTTP vals expect an exported "fetch handler"
47// This is how you "run the server" in Val Town with Hono
48export default app.fetch;
25 const handleScan = async (productCode: string) => {
26 try {
27 const response = await fetch(`/manual?code=${encodeURIComponent(productCode)}`);
28
29 if (!response.ok) {
43
44 try {
45 const response = await fetch('/chat', {
46 method: 'POST',
47 body: JSON.stringify({
107
108 try {
109 await fetch('/clear-conversation', { method: 'POST' });
110 setConversation([]);
111 } catch (error) {
19 };
20 // console.log(req.headers);
21 await fetch(API, {
22 method: "POST",
23 body: JSON.stringify(data),
174 console.debug("Creating new tool with name:", toolName);
175 const createToolStart = Date.now();
176 const toolResponse = await fetch(`${VALTOWN_URL}/vals`, {
177 method: "POST",
178 headers: {
252 console.debug("Manifesto config generated:", manifestoConfig);
253
254 // Fetch the original manifest
255 console.debug("Fetching original manifesto...");
256 const originalManifestoResponse = await fetch(`${VALTOWN_URL}/vals/513b3c1c-ffde-11ef-948c-569c3dd06744`, {
257 method: "GET",
258 headers: {
264 if (!originalManifestoResponse.ok) {
265 const errorText = await originalManifestoResponse.text();
266 console.error("Failed to fetch original manifesto:", originalManifestoResponse.status, errorText);
267 throw new Error(`Failed to fetch original manifesto. Status: ${originalManifestoResponse.status}`);
268 }
269
270 const originalManifestData = await originalManifestoResponse.json();
271 console.debug("Original manifesto fetched successfully:", originalManifestData);
272
273 const originalManifestoCode = originalManifestData.code;