Forked from neverstew/createVal
Public
Script
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
38
39
40
41
42
43
44
45
46
47
48
49
50
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"; // Added privacy type
version: number;
runEndAt: string;
runStartAt: string;
logs: any[];
output: object;
error: object | null;
readme: string | null;
likeCount: number;
referenceCount: number;
}
interface CreateValArgs {
token: string;
code: string;
name?: string;
readme?: string;
privacy?: "public" | "unlisted" | "private"; // Added privacy option
type?: "http" | "script" | "email";
}
export function createVal({ token, code, name, readme, privacy, type }: CreateValArgs): Promise<ValResponse> {
const body: Record<string, unknown> = {
code,
token,
name,
readme,
privacy,
type,
};
return fetchJSON("https://api.val.town/v1/vals", {
headers: {
Authorization: `Bearer ${token}`,
},
method: "POST",
body: JSON.stringify(body),
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
v9 was merged from the PR "add type param (http, script, etc)" by mharris717
Comments
Nobody has commented on this val yet: be the first!
August 8, 2024