1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
import { runVal } from "https://esm.town/v/std/runVal";
export async function createGeneratedVal({ description, valTownKey }: {
description: string;
valTownKey: string;
}) {
const code = await runVal(
"andreterron.generateValCodeAPI",
description,
);
const val = await fetchJSON(
`https://api.val.town/v1/vals`,
{
method: "POST",
headers: {
Authorization: `Bearer ${valTownKey}`,
},
body: JSON.stringify({
code,
}),
},
);
return val;
}