5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
8 headers: {
9 "User-Agent": "", // to transpile TS to JS
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
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 }
56 })();
57
58 // Fetch projects from the CMS
59 const projectsCMS = async (): Promise<any> => {
60 const API_URL = "https://cd25-projects-cms.sa-60b.workers.dev/api/cms_projects";
61 debugLog("Fetching projects from CMS:", API_URL);
62 try {
63 const response = await fetch(API_URL, {
64 method: "GET",
65 headers: {
68 });
69 if (!response.ok) {
70 console.error(`Error fetching projects: ${response.status} ${response.statusText}`);
71 return;
72 }
73 const projects = await response.json();
74 debugLog("Projects fetched successfully:", projects);
75 return projects;
76 } catch (error) {
77 console.error("Error in projectsCMS fetch:", error);
78 }
79 };
54 async function generateBuyerPersona() {
55 try {
56 const response = await fetch('/api/generate-buyer-persona', {
57 method: 'POST',
58 headers: {
83 async function identifyProblems() {
84 try {
85 const response = await fetch('/api/identify-problems', {
86 method: 'POST',
87 headers: {
110 async function generateSolutions() {
111 try {
112 const response = await fetch('/api/generate-solutions', {
113 method: 'POST',
114 headers: {
137 async function createIrresistibleOffer() {
138 try {
139 const response = await fetch('/api/create-offer', {
140 method: 'POST',
141 headers: {
7 * 1. User enters a Knowunity document URL on the homepage
8 * 2. Client-side JS redirects to /get with the URL
9 * 3. Server extracts UUID and fetches the direct document URL
10 * 4. Server redirects user to the document URL
11 */
149 const [uuid] = uuidMatch;
150
151 // Fetch document details
152 const response = await fetch(`https://apiedge-eu-central-1.knowunity.com/knows/${uuid}`);
153
154 if (!response.ok) {
155 return c.text("Failed to fetch document details: " + response.status, 500);
156 }
157
170});
171
172export default app.fetch;
1import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
2import { form } from "https://esm.town/v/stevekrouse/date_me_form";
3import browse from "https://esm.town/v/stevekrouse/dateme_browse";
13app.get("/faq", faq);
14app.get("/rss.xml", c => dateMeRSS(c.req as unknown as Request));
15export default modifyFetchHandler(app.fetch, {
16 style: `@media (max-width: 500px) {
17 .github-fork-ribbon {
36 "integrity": "sha512-OF8fFQSkbL7vJY9rfuegK1R7sPgQ6kFMkDamiEccNUvieQ+3urzfDFI616oPl8V7T9zRmnTkSjMOImYCAVRVuw==",
37 "dependencies": [
38 "@libsql/isomorphic-fetch",
39 "@libsql/isomorphic-ws",
40 "js-base64",
41 "node-fetch"
42 ]
43 },
44 "@libsql/isomorphic-fetch@0.3.1": {
45 "integrity": "sha512-6kK3SUK5Uu56zPq/Las620n5aS9xJq+jMBcNSOmjhNf/MUvdyji4vrMTqD7ptY7/4/CAVEAYDeotUz60LNQHtw=="
46 },
101 "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw=="
102 },
103 "fetch-blob@3.2.0": {
104 "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
105 "dependencies": [
111 "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
112 "dependencies": [
113 "fetch-blob"
114 ]
115 },
143 "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
144 },
145 "node-fetch@3.3.2": {
146 "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
147 "dependencies": [
148 "data-uri-to-buffer",
149 "fetch-blob",
150 "formdata-polyfill"
151 ]
25 }
26
27 const response = await fetch(`/fork?url=${encodeURIComponent(projectUrl)}`, {
28 method: "POST",
29 headers: {
202});
203
204// HTTP vals expect an exported "fetch handler"
205// This is how you "run the server" in Val Town with Hono
206export default app.fetch;