1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 07:44:48 -05:00
denoland-deno/cli/tests/testdata/resolve_dns.ts
Kitson Kelly a065604155
feat(cli): enable useUnknownInCatchVariables by default (#12547)
Closes #11826

**BREAKING CHANGE** this behaviour was disable when introduced in Deno 1.14/TypeScript 4.4. It will highlight code that unsafely handles variables that are caught, and will cause type errors in unsafe code.
2021-10-28 08:43:40 +11:00

46 lines
1.2 KiB
TypeScript

const nameServer = { nameServer: { ipAddr: "127.0.0.1", port: 4553 } };
const [a, aaaa, aname, cname, mx, ptr, srv, txt] = await Promise.all([
Deno.resolveDns("www.example.com", "A", nameServer),
Deno.resolveDns("www.example.com", "AAAA", nameServer),
Deno.resolveDns("www.example.com", "ANAME", nameServer),
Deno.resolveDns("foo", "CNAME", nameServer),
Deno.resolveDns("www.example.com", "MX", nameServer),
Deno.resolveDns("5.6.7.8", "PTR", nameServer),
Deno.resolveDns("_Service._TCP.example.com", "SRV", nameServer),
Deno.resolveDns("www.example.com", "TXT", nameServer),
]);
console.log("A");
console.log(JSON.stringify(a));
console.log("AAAA");
console.log(JSON.stringify(aaaa));
console.log("ANAME");
console.log(JSON.stringify(aname));
console.log("CNAME");
console.log(JSON.stringify(cname));
console.log("MX");
console.log(JSON.stringify(mx));
console.log("PTR");
console.log(JSON.stringify(ptr));
console.log("SRV");
console.log(JSON.stringify(srv));
console.log("TXT");
console.log(JSON.stringify(txt));
try {
await Deno.resolveDns("not-found-example.com", "A", nameServer);
} catch (e) {
console.log(
`Error ${
e instanceof Error ? e.name : "[non-error]"
} thrown for not-found-example.com`,
);
}