-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpRequestQueueTest.ts
45 lines (34 loc) · 986 Bytes
/
HttpRequestQueueTest.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
34
35
36
37
38
39
40
41
42
43
44
45
import * as ACME from "./acme.ts"
const httpRequestQueue = ACME.createHttpRequestQueue();
Deno.serve(
{
hostname: "0.0.0.0",
port: 80,
onListen: () =>
{
console.debug("listener ready!");
ACME.getCertificateWithHttp("deno-acme-test1.wille.io",
{
acmeDirectoryUrl: "https://acme-staging-v02.api.letsencrypt.org/directory",
yourEmail: "[email protected]",
httpRequestQueue,
}
).then(() => { console.log("DONE!"); Deno.exit(0); });
}
},
async (request) =>
{
console.log("request received!");
const response = await new Promise<Response | null>((resolver) =>
{
httpRequestQueue.push({ request, resolver });
});
console.log("request response!", response);
if (!response)
{
return new Response(null, { status: 400 });
}
return response;
}
); // NOTE: event loop now active!
console.debug("listener starting up ...");