Skip to content

Commit

Permalink
Merge pull request #3171 from cloudflare/yagiz/add-dns-constants
Browse files Browse the repository at this point in the history
add node:dns constants
  • Loading branch information
anonrig authored Nov 25, 2024
2 parents 0a67595 + af4799d commit 7cae939
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ wd_ts_bundle(
"*.ts",
"*.js",
"assert/*.ts",
"dns/*.ts",
"stream/*.js",
"path/*.ts",
"util/*.ts",
Expand Down
5 changes: 5 additions & 0 deletions src/node/dns.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { default as dnsUtil } from 'node-internal:dns';
import * as errorCodes from 'node-internal:internal_dns_constants';

export * from 'node-internal:internal_dns_constants';

export const getServers = dnsUtil.getServers.bind(dnsUtil);
export const lookup = dnsUtil.lookup.bind(dnsUtil);
Expand Down Expand Up @@ -44,4 +47,6 @@ export default {
setDefaultResultOrder,
getDefaultResultOrder,
setServers,

...errorCodes,
};
7 changes: 7 additions & 0 deletions src/node/dns/promises.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as errorCodes from 'node-internal:internal_dns_constants';

export * from 'node-internal:internal_dns_constants';

export default {
...errorCodes,
};
24 changes: 24 additions & 0 deletions src/node/internal/internal_dns_constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const NODATA = 'ENODATA';
export const FORMERR = 'EFORMERR';
export const SERVFAIL = 'ESERVFAIL';
export const NOTFOUND = 'ENOTFOUND';
export const NOTIMP = 'ENOTIMP';
export const REFUSED = 'EREFUSED';
export const BADQUERY = 'EBADQUERY';
export const BADNAME = 'EBADNAME';
export const BADFAMILY = 'EBADFAMILY';
export const BADRESP = 'EBADRESP';
export const CONNREFUSED = 'ECONNREFUSED';
export const TIMEOUT = 'ETIMEOUT';
export const EOF = 'EOF';
export const FILE = 'EFILE';
export const NOMEM = 'ENOMEM';
export const DESTRUCTION = 'EDESTRUCTION';
export const BADSTR = 'EBADSTR';
export const BADFLAGS = 'EBADFLAGS';
export const NONAME = 'ENONAME';
export const BADHINTS = 'EBADHINTS';
export const NOTINITIALIZED = 'ENOTINITIALIZED';
export const LOADIPHLPAPI = 'ELOADIPHLPAPI';
export const ADDRGETNETWORKPARAMS = 'EADDRGETNETWORKPARAMS';
export const CANCELLED = 'ECANCELLED';
1 change: 1 addition & 0 deletions src/node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"paths": {
"node:*": ["./*"],
"node:assert/*": ["./*"],
"node:dns/*": ["./*"],
"node:util/*": ["./*"],
"node:path/*": ["./*"],
"node:stream/*": ["./*"],
Expand Down
8 changes: 8 additions & 0 deletions src/workerd/api/node/tests/dns-nodejs-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dns from 'node:dns';
import dnsPromises from 'node:dns/promises';
import { strictEqual } from 'node:assert';

export const functionsExist = {
Expand Down Expand Up @@ -29,3 +30,10 @@ export const functionsExist = {
}
},
};

export const errorCodesExist = {
async test() {
strictEqual(typeof dns.NODATA, 'string');
strictEqual(typeof dnsPromises.NODATA, 'string');
},
};

0 comments on commit 7cae939

Please sign in to comment.