131 if (failedFiles.length > 0) {
132 const failedFilesList = failedFiles.map(f => `'${f.path}': ${f.error}`).join(", ");
133 throw new Error(`Failed to fetch content for files: ${failedFilesList}`);
134 }
135
167});
168
169// HTTP vals expect an exported "fetch handler"
170// This is how you "run the server" in Val Town with Hono
171export default app.fetch;
45});
46
47// HTTP vals expect an exported "fetch handler"
48// This is how you "run the server" in Val Town with Hono
49export default app.fetch;
46});
47
48// HTTP vals expect an exported "fetch handler"
49// This is how you "run the server" in Val Town with Hono
50export default app.fetch;
39 try {
40 setLoading(true);
41 const response = await fetch("/generate-image", {
42 method: "POST",
43 headers: {
39 try {
40 setLoading(true);
41 const response = await fetch("/generate-image", {
42 method: "POST",
43 headers: {
70 setError("");
71 try {
72 const response = await fetch("/api/adopt", {
73 method: "POST",
74 headers: {
1import { rawFetch } from "https://esm.town/v/std/rawFetch";
2
3export async function getStars() {
4 return await feedbinFetch("https://api.feedbin.com/v2/starred_entries.json", {});
5}
6
7export function getEntry(entryId: number) {
8 return feedbinFetch(`https://api.feedbin.com/v2/entries/${entryId}.json`, {});
9}
10
11async function feedbinFetch(url: string, opts: any) {
12 try {
13 const username = Deno.env.get("FEEDBIN_USER");
16 opts.headers = opts.headers || {};
17 opts.headers["Authorization"] = "Basic " + btoa(username + ":" + password);
18 const res = await rawFetch(url, opts);
19 if (res.ok === false) {
20 console.log(res);
12
13- `/push` will copy the contents from a list of vals specified in `config.json` and push them to a GitHub repo
14- `/deploy` is a GitHub webhook URL that will fetch contents from GitHub and update the code on Val Town
15
161. Fork this val
271. Add a `VAL_SECRET` env var to the val. Use this secret to sign the webhook POST request to the `/push` endpoint. Use this endpoint to commit vals from Val Town to your GitHub repo.
28
29### Example push to GitHub fetch
30
31You can use this example to POST to the `/push` endpoint to copy vals to GitHub.
46 const signature = await sign(body, secret);
47
48 const res = await fetch(url, {
49 method: "POST",
50 body,
89- [x] Monkey test
90- [x] Add setup instructions to readme
91- [x] Add example code for private webhook fetch
92- [x] Make val and repo public
93- [ ] Check modified date before export to GitHub??
43});
44
45// HTTP vals expect an exported "fetch handler"
46// This is how you "run the server" in Val Town with Hono
47export default app.fetch;
39 try {
40 setLoading(true);
41 const response = await fetch("/generate-image", {
42 method: "POST",
43 headers: {