char/avril

(wip) why'd you have to go and make things so complicaaaaated?

git clone https://git.t4t.associates/char/avril

Charlotte Somport http extension to typescript495c9a5

main
1.5 KiB35 linesraw
1declare module "ext:core/ops" {
2  export type HttpAddress =
3    | { transport: "tcp"; hostname: string; port: number }
4    | { transport: "unix"; path: string | null };
5  export type HttpListener = [id: number, address: HttpAddress];
6  export type HttpRequestMetadata = [
7    id: number,
8    method: string,
9    url: string,
10    headers: [name: string, value: string][],
11    hasBody: boolean,
12    remote: HttpAddress,
13  ];
14  export function op_http_listen(address: HttpAddress & { __proto__?: null }): HttpListener;
15  export function op_http_cli_listen(unit: null): HttpListener;
16  export function op_http_next(id: number): Promise<HttpRequestMetadata | null>;
17  export function op_http_finished(id: number): Promise<null>;
18  export function op_http_stop(args: [id: number, force: boolean]): null;
19  export function op_http_read(id: number): Promise<Uint8Array<ArrayBuffer> | null>;
20  export function op_http_respond(
21    args: [
22      id: number,
23      status: number,
24      headers: [name: string, value: string][],
25      bytes: Uint8Array<ArrayBuffer> | null,
26      streaming: boolean,
27    ],
28  ): boolean;
29  export function op_http_write(args: [id: number, bytes: Uint8Array<ArrayBuffer> | null]): Promise<boolean>;
30  export function op_http_wait(id: number): Promise<boolean>;
31  export function op_http_upgrade(
32    args: [id: number, protocol: string | null],
33  ): [socket: number, headers: [name: string, value: string][]];
34  export function op_http_cancel(id: number): null;
35}