HtmlSpecialCharsDemoindex.ts1 match
15app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
1617export default app.fetch;
HtmlSpecialCharsDemoApp.tsx1 match
67useEffect(() => {
8fetch("https://htmlspecialcharsdemo.val.run/api/data")
9.then(resp => resp.text())
10.then(text => setData(text));
1export default async function(req: Request): Promise<Response> {
2const url = new URL(req.url);
3return fetch(new URL(url.pathname + url.search, "https://charmaine--6a875a3820ff11f0b157569c3dd06744.web.val.run"), {
4method: req.method,
5headers: req.headers,
28const projectUrl = `https://www.val.town/x/${username}/${projectName}`;
2930// First, get the project ID by fetching the project details
31let projectId;
32let endpointUrl: string | undefined; // Initialize as undefined, explicitly type
33try {
34const projectResponse = await fetch(`https://api.val.town/v1/alias/projects/${username}/${projectName}`, {
35headers: {
36"Authorization": `Bearer ${apiKey}`,
49}
5051// Fetch the project files to get the endpoint URL
52const filesResponse = await fetch(`https://api.val.town/v1/projects/${projectId}/files?path=`, {
53headers: {
54"Authorization": `Bearer ${apiKey}`,
5758if (!filesResponse.ok) {
59// Still throw if fetching files fails
60throw new Error(`Failed to get project files: ${filesResponse.status}`);
61}
73}
74} catch (error) {
75// Catch errors from fetching project details or files (but not the missing endpoint specifically)
76console.error("Error getting project details or files:", error);
77// Rethrow because fetching project details is critical for proceeding
78throw new Error(`Error preparing project details: ${error.message}`);
79}
97try {
98// First, get the val ID
99const valResponse = await fetch(`https://api.val.town/v1/alias/${valOwner}/${valName}`, {
100headers: {
101"Authorization": `Bearer ${apiKey}`,
104105if (!valResponse.ok) {
106throw new Error(`Failed to fetch val details: ${valResponse.status}`);
107}
108122const redirectCode = `export default async function(req: Request): Promise<Response> {
123const url = new URL(req.url);
124return fetch(new URL(url.pathname + url.search, "${endpointUrl}"), {
125method: req.method,
126headers: req.headers,
148console.log(`Version update body for ${valOwner}/${valName}:`, JSON.stringify(versionUpdateBody).substring(0, 200) + "...");
149150const versionUpdateResponse = await fetch(versionUpdateUrl, {
151method: "POST",
152headers: {
174};
175176const readmeUpdateResponse = await fetch(readmeUpdateUrl, {
177method: "PUT", // Use PUT as documented for updating val properties
178headers: {
3// Define an intermediate type for the processing array
4interface ProcessingValInfo extends ValInfo {
5val?: any; // Store the fetched val data here
6success: boolean;
7error?: string;
34// Use existing project
35projectId = existingProjectId;
36// Fetch existing project details to get name and author
37const projectDetailsResponse = await fetch(`https://api.val.town/v1/projects/${projectId}`, {
38headers: { "Authorization": `Bearer ${apiKey}` },
39});
40if (!projectDetailsResponse.ok) {
41const errorText = await projectDetailsResponse.text();
42throw new Error(`Failed to fetch existing project details: ${errorText}`);
43}
44const projectDetails = await projectDetailsResponse.json();
6768// Create the new project
69const projectResponse = await fetch("https://api.val.town/v1/projects", {
70method: "POST",
71headers: {
100const convertedVals: ProcessingValInfo[] = []; // Use the defined type here
101102// First pass: fetch all vals and track them
103for (const valInfo of vals) {
104try {
105// Fetch the val details
106const valResponse = await fetch(`https://api.val.town/v1/alias/${valInfo.username}/${valInfo.valName}`, {
107headers: { "Authorization": `Bearer ${apiKey}` },
108});
115valName: valInfo.valName,
116success: false,
117error: `Failed to fetch val: ${errorText}`,
118});
119continue;
131username: valInfo.username,
132valName: valInfo.valName,
133val: val, // Store the fetched val
134success: true,
135});
155156// Add the file to the project (use the determined projectId)
157const fileResponse = await fetch(`https://api.val.town/v1/projects/${projectId}/files?path=${filePath}`, {
158method: "POST",
159headers: {
188// Generate and add README.md
189const readmeContent = generateReadme(finalProjectName, vals, convertedVals);
190await fetch(`https://api.val.town/v1/projects/${projectId}/files/README.md`, {
191method: "POST",
192headers: {
32let func = `(async () => {
33try {
34await fetch(import.meta.url, {
35method: "POST",
36headers: {
cerebras_coderindex.ts1 match
181182try {
183const response = await fetch("/", {
184method: "POST",
185body: JSON.stringify({
cerebras_coderindex.ts1 match
181182try {
183const response = await fetch("/", {
184method: "POST",
185body: JSON.stringify({
2829// create http request
30const res = await fetch("https://api.capacities.io/save-to-daily-note", {
31method: "POST",
32headers: {
2829// create http request
30const res = await fetch("https://api.capacities.io/save-to-daily-note", {
31method: "POST",
32headers: {