43});
44
45export default app.fetch;
50 try {
51 const aliasUrl = `https://api.val.town/v1/alias/${valOwner}/${valName}`;
52 console.log(`Fetching val ID from alias: ${aliasUrl}`);
53
54 aliasResponse = await fetch(aliasUrl, {
55 headers: {
56 "Authorization": `Bearer ${apiKey}`,
92 console.log(`Updating val at: ${updateUrl} using PUT method`);
93
94 updateResponse = await fetch(updateUrl, {
95 method: "PUT",
96 headers: {
38
39 // Create a new project
40 const projectResponse = await fetch("https://api.val.town/v1/projects", {
41 method: "POST",
42 headers: {
64 const importedVals = {};
65
66 // First pass: fetch all vals and track them
67 const convertedVals = [];
68 for (const valInfo of vals) {
69 try {
70 // Fetch the val details
71 const valResponse = await fetch(`https://api.val.town/v1/alias/${valInfo.username}/${valInfo.valName}`, {
72 headers: { "Authorization": `Bearer ${apiKey}` },
73 });
78 ...valInfo,
79 success: false,
80 error: `Failed to fetch val: ${errorText}`,
81 });
82 continue;
114 const encodedPath = encodeURIComponent(filePath);
115
116 const fileResponse = await fetch(`https://api.val.town/v1/projects/${project.id}/files/${encodedPath}`, {
117 method: "POST",
118 headers: {
139 // Generate and add README.md
140 const readmeContent = generateReadme(project.name, vals, convertedVals);
141 await fetch(`https://api.val.town/v1/projects/${project.id}/files/README.md`, {
142 method: "POST",
143 headers: {
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const discordWebhook = async ({
8 content: string;
9}) => {
10 const res = await fetch(url, {
11 method: "POST",
12 redirect: "follow",
19 : Math.floor((Date.now() - 2 * 24 * 60 * 60 * 1000) / 1000);
20
21 // Fetch and log tweets
22 const response = await socialDataSearch(`${query} since_time:${timeFrame}`);
23 console.log("Response from socialDataSearch:", response);
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function socialDataSearch(query: string): Promise<SocialDataResponse> {
4 const url = new URL("https://stevekrouse-socialdataproxy.web.val.run/twitter/search");
5 url.searchParams.set("query", query);
6 return await fetchJSON(url.toString(), {
7 bearer: Deno.env.get("valtown"),
8 });
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 {
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;
25 }
26
27 const response = await fetch(`/fork?url=${encodeURIComponent(projectUrl)}`, {
28 method: "POST",
29 headers: {
14}
15
16async function fetchPromos(): Promise<Promo[]> {
17 try {
18 const response = await fetch(FRONTIER_URL);
19 const html = await response.text();
20
109 return promos;
110 } catch (error) {
111 console.error("Failed to fetch promos:", error);
112 throw error;
113 }
118app.get("/", async (c) => {
119 try {
120 const promos = await fetchPromos();
121 return c.json({
122 success: true,
131 success: false,
132 timestamp: new Date().toISOString(),
133 error: error.message || "Failed to fetch promotions",
134 },
135 500,
141// deno-lint-ignore require-await
142export default async function server(request: Request): Promise<Response> {
143 return app.fetch(request);
144}
145