diggy 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +73 -53
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diggy",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Multi-backend DNS resolver for Node.js/Browser — supports dig, DNS over HTTPS, and native Node.js DNS.",
5
5
  "repository": "git@github.com:OzzyCzech/diggy.git",
6
6
  "author": "Roman Ožana <roman@ozana.cz>",
package/readme.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # 👾 Diggy
2
2
 
3
+ [![NPM Downloads](https://img.shields.io/npm/dm/diggy?style=for-the-badge)](https://www.npmjs.com/package/diggy)
4
+ [![NPM Version](https://img.shields.io/npm/v/diggy?style=for-the-badge)](https://www.npmjs.com/package/diggy)
5
+ [![NPM License](https://img.shields.io/npm/l/diggy?style=for-the-badge)](https://github.com/OzzyCzech/diggy/blob/main/LICENSE)
6
+ [![Last Commit](https://img.shields.io/github/last-commit/OzzyCzech/diggy?style=for-the-badge)](https://github.com/OzzyCzech/diggy/commits/main)
7
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/OzzyCzech/diggy/main.yml?style=for-the-badge)](https://github.com/OzzyCzech/diggy/actions)
8
+
3
9
  👾 **Diggy** is a flexible, multi-backend JavaScript **DNS resolver** for fetching **DNS records**
4
10
  with support for various resolution methods including DNS over HTTPS, native `dig` commands, and Node.js built-in DNS
5
11
  functionality.
@@ -60,9 +66,9 @@ const records: AnyDNSRecord[] = await getDnsRecords('example.com', 'A');
60
66
 
61
67
  ```typescript
62
68
  function getDnsRecords(
63
- host: string,
64
- type?: string,
65
- resolver?: string | BuildInDNSResolver | DNSResolver,
69
+ host: string,
70
+ type?: string,
71
+ resolver?: string | BuildInDNSResolver | DNSResolver,
66
72
  ): Promise<AnyDNSRecord[]>
67
73
  ```
68
74
 
@@ -74,6 +80,20 @@ function getDnsRecords(
74
80
 
75
81
  **Returns:** Promise resolving to an array of DNS records
76
82
 
83
+ ## 🌍 Browser Usage
84
+
85
+ You can also use Diggy in the browser via ESM imports. This allows you to fetch DNS records directly from client-side
86
+ JavaScript. There are built-in resolvers for Google and Cloudflare DNS over HTTPS, which work seamlessly in the browser.
87
+
88
+ ```html
89
+
90
+ <script type="module">
91
+ import { getDnsRecords } from 'https://esm.sh/diggy';
92
+
93
+ const records = await getDnsRecords('ozana.cz');
94
+ </script>
95
+ ```
96
+
77
97
  ## 🌐 Available Resolvers
78
98
 
79
99
  ### Built-in Resolvers
@@ -94,12 +114,12 @@ const records = await getDnsRecords('example.com', 'A', "nodejs");
94
114
  const records = await getDnsRecords('example.com', 'A', "dig");
95
115
  ```
96
116
 
97
- | Resolver | Description | Environment |
98
- |--------------|-----------------------------|---------------------------|
99
- | `google` | Google DNS over HTTPS | Works in Browser |
100
- | `cloudflare` | Cloudflare DNS over HTTPS | Works in Browser |
101
- | `nodejs` | Node.js built-in DNS module | Node.js runtime |
102
- | `dig` | Native dig command | `dig` installed on system |
117
+ | Resolver | Description | Environment |
118
+ |--------------|-----------------------------|----------------------------------------|
119
+ | `google` | Google DNS over HTTPS | Browsers, Node.js |
120
+ | `cloudflare` | Cloudflare DNS over HTTPS | Browsers, Node.js |
121
+ | `nodejs` | Node.js built-in DNS module | Node.js only |
122
+ | `dig` | Native dig command | Node.js only, requires `dig` installed |
103
123
 
104
124
  ### Configure built-in resolvers
105
125
 
@@ -134,8 +154,8 @@ You can also **create your own custom resolver** by implementing the `DNSResolve
134
154
 
135
155
  ```typescript
136
156
  export type DNSResolver = (
137
- host: string,
138
- type: DNSRecordType,
157
+ host: string,
158
+ type: DNSRecordType,
139
159
  ) => Promise<AnyDNSRecord[]>;
140
160
  ```
141
161
 
@@ -161,19 +181,19 @@ DNS records are returned as an array of objects with the following structure:
161
181
  import { CaaRecordData, MxRecordData, SoaRecordData, SrvRecordData, NaptrRecordData } from "./types";
162
182
 
163
183
  interface AnyDNSRecord {
164
- name: string; // Domain name
165
- type: string; // Record type (A, AAAA, MX, etc.)
166
- ttl: number; // Time-to-live in seconds
167
-
168
- // Record data (format varies by type)
169
- data:
170
- | string
171
- | string[]
172
- | MxRecordData
173
- | SoaRecordData
174
- | CaaRecordData
175
- | NaptrRecordData
176
- | SrvRecordData;
184
+ name: string; // Domain name
185
+ type: string; // Record type (A, AAAA, MX, etc.)
186
+ ttl: number; // Time-to-live in seconds
187
+
188
+ // Record data (format varies by type)
189
+ data:
190
+ | string
191
+ | string[]
192
+ | MxRecordData
193
+ | SoaRecordData
194
+ | CaaRecordData
195
+ | NaptrRecordData
196
+ | SrvRecordData;
177
197
  }
178
198
  ```
179
199
 
@@ -181,35 +201,35 @@ interface AnyDNSRecord {
181
201
 
182
202
  ```json
183
203
  [
184
- {
185
- "name": "example.com",
186
- "type": "SOA",
187
- "ttl": 3600,
188
- "data": {
189
- "nsname": "ns1.example.com.",
190
- "hostmaster": "hostmaster.example.com.",
191
- "serial": 2025051204,
192
- "refresh": 10800,
193
- "retry": 3600,
194
- "expire": 604800,
195
- "minttl": 3600
196
- }
197
- },
198
- {
199
- "name": "example.cz",
200
- "type": "A",
201
- "ttl": 1800,
202
- "data": "66.33.66.33"
203
- },
204
- {
205
- "name": "example.cz",
206
- "type": "MX",
207
- "ttl": 60,
208
- "data": {
209
- "priority": 10,
210
- "exchange": "mail.example.com"
211
- }
212
- }
204
+ {
205
+ "name": "example.com",
206
+ "type": "SOA",
207
+ "ttl": 3600,
208
+ "data": {
209
+ "nsname": "ns1.example.com.",
210
+ "hostmaster": "hostmaster.example.com.",
211
+ "serial": 2025051204,
212
+ "refresh": 10800,
213
+ "retry": 3600,
214
+ "expire": 604800,
215
+ "minttl": 3600
216
+ }
217
+ },
218
+ {
219
+ "name": "example.cz",
220
+ "type": "A",
221
+ "ttl": 1800,
222
+ "data": "66.33.66.33"
223
+ },
224
+ {
225
+ "name": "example.cz",
226
+ "type": "MX",
227
+ "ttl": 60,
228
+ "data": {
229
+ "priority": 10,
230
+ "exchange": "mail.example.com"
231
+ }
232
+ }
213
233
  ]
214
234
  ```
215
235