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
26
27
28
29
30
31
32
33
34
35
36
37
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export interface ValResponse {
id: string;
author: {
id: string;
username: string;
};
name: string;
code: string;
public: boolean;
privacy: "public" | "unlisted" | "private";
version: number;
runEndAt: string;
runStartAt: string;
logs: any[];
output: object;
error: object | null;
readme: string | null;
likeCount: number;
referenceCount: number;
}
interface CreateValArgs {
code: string;
name?: string;
readme?: string;
privacy?: "public" | "unlisted" | "private";
}
export function createVal({ token, ...data }: { token?: string } & CreateValArgs): Promise<ValResponse> {
return fetchJSON("https://api.val.town/v1/vals", {
bearer: token || Deno.env.get("valtown"),
method: "PUT",
body: JSON.stringify(data),
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
May 23, 2024