forked from predetermined/aqua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.ts
33 lines (26 loc) · 868 Bytes
/
deploy.ts
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
import OriginalAqua, { Options as OriginalOptions } from "./aqua.ts";
import { getAquaRequestFromNativeRequest } from "./shared.ts";
export * from "./aqua.ts";
declare var addEventListener: (
eventName: string,
handler: (event: Deno.RequestEvent) => void,
) => void;
export type Options = Omit<OriginalOptions, "tls">;
export default class Aqua extends OriginalAqua {
public _internal = {
mockRequest: this.mockRequest.bind(this),
};
private async mockRequest(event: Deno.RequestEvent) {
const req = await getAquaRequestFromNativeRequest(event);
this.handleRequest(req);
}
constructor(options?: Options) {
super(-1, { ...options });
}
protected listen(_port: number) {
addEventListener("fetch", async (event) => {
const req = await getAquaRequestFromNativeRequest(event);
this.handleRequest(req);
});
}
}