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
// #folder:vtApiClient
import { fetch } from "https://esm.town/v/std/fetch?v=4";
export type Profile = { s; id: string; bio: string; username: string; profileImageUrl: string };
export type Val = {
id: string;
author: {
id: string;
username: string;
};
name: string;
code: string;
public: boolean;
privacy: "public" | "private";
version: number;
runEndAt: string;
runStartAt: string;
logs: any[];
output: object;
error: object | null;
readme: string | null;
likeCount: number;
referenceCount: number;
};
export type ExpressionResult = string | number | Record<string, any> | any[] | boolean;
export class ValTownClient {
private baseURL: string;
private authenticated: boolean;
private authorization: string | undefined;
public alias: AliasEndpoint;
public eval: EvalEndpoint;
public me: MeEndpoint;
public users: UsersEndpoint;
public vals: ValsEndpoint;
public run: RunEndpoint;
public endpoint: Endpoint;
constructor({
baseURL = "https://api.val.town/v1",
authenticated = false,
}: {
baseURL?: string;
authenticated?: boolean;
} = {}) {
this.baseURL = baseURL;
πŸ‘† This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data β€” all from the browser.