Avatar

@octref

1 like7 public vals
Joined May 26, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { updateGHContent } from "https://esm.town/v/octref/updateGHContent";
import { ghContent } from "https://esm.town/v/octref/ghContent";
export async function updateISBNFile(isbn: string) {
const ISBN_PATH = "data/mine/books-isbn.json";
const content = await ghContent(ISBN_PATH);
const books = JSON.parse(content);
books.unshift({
isbn,
events: [
{
time: new Date().toISOString().split("T")[0],
type: "todo",
},
],
});
await updateGHContent(
ISBN_PATH,
JSON.stringify(books, null, 2),
);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { runFunesUpdate } from "https://esm.town/v/octref/runFunesUpdate";
import { updateGHContent } from "https://esm.town/v/octref/updateGHContent";
import { ghContent2 } from "https://esm.town/v/octref/ghContent2";
export async function handleISBNBook(req: express.Request, res: express.Response) {
const ISBN_PATH = "data/mine/books-isbn.json";
const { content, sha } = await ghContent2(ISBN_PATH);
const books = JSON.parse(content);
books.unshift({
isbn: req.query.isbn,
events: [
{
time: new Date().toISOString().split("T")[0],
type: "todo",
},
],
});
const newContent = JSON.stringify(books, null, 2);
await updateGHContent(ISBN_PATH, newContent, sha);
await runFunesUpdate();
return res.send(`<pre><code>${newContent}</code></pre>`);
}
1
2
3
4
5
6
7
8
import { myTestForm } from "https://esm.town/v/octref/myTestForm";
// View at https://api.val.town/v1/express/stevekrouse.expressHTMLExample?name=Steve
export async function expressHTMLExample(req: express.Request, res: express.Response) {
myTestForm.push(req.query.name || req.body.name);
return res.send(`<h1>Hi ${req.query.name || req.body.name}!</h1>`);
}
// Forked from @stevekrouse.expressHTMLExample
1
2
// set by octref.expressHTMLExample at 2023-05-26T17:02:19.205Z
export let myTestForm = ["hey", "pine"];
1
export let testForm = [];
1
2
3
4
5
6
import { myTestForm } from "https://esm.town/v/octref/myTestForm";
export function handleForm(params) {
myTestForm.push(params);
return `Thanks for your submission ${params.name}`;
}
1
2
3
export function myApi(name) {
return "hi " + name;
}
Next