@openstatus/sdk-node 0.0.1 → 0.0.2
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.
- package/README.md +301 -130
- package/esm/gen/openstatus/monitor/v1/monitor_pb.d.ts +36 -36
- package/esm/gen/openstatus/monitor/v1/monitor_pb.d.ts.map +1 -1
- package/esm/gen/openstatus/monitor/v1/monitor_pb.js +37 -37
- package/esm/gen/openstatus/monitor/v1/service_pb.d.ts +156 -0
- package/esm/gen/openstatus/monitor/v1/service_pb.d.ts.map +1 -1
- package/esm/gen/openstatus/monitor/v1/service_pb.js +43 -13
- package/esm/mod.d.ts +20 -12
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +17 -11
- package/package.json +1 -1
- package/script/gen/openstatus/monitor/v1/monitor_pb.d.ts +36 -36
- package/script/gen/openstatus/monitor/v1/monitor_pb.d.ts.map +1 -1
- package/script/gen/openstatus/monitor/v1/monitor_pb.js +37 -37
- package/script/gen/openstatus/monitor/v1/service_pb.d.ts +156 -0
- package/script/gen/openstatus/monitor/v1/service_pb.d.ts.map +1 -1
- package/script/gen/openstatus/monitor/v1/service_pb.js +44 -14
- package/script/mod.d.ts +20 -12
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +21 -12
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# OpenStatus Node.js SDK
|
|
2
2
|
|
|
3
|
-
[](https://jsr.io/@openstatus/sdk-node)
|
|
4
|
+
[](https://www.npmjs.com/package/@openstatus/sdk-node)
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
|
|
7
7
|
Official Node.js SDK for [OpenStatus](https://openstatus.dev) - the open-source
|
|
@@ -13,52 +13,62 @@ monitoring platform.
|
|
|
13
13
|
- **TCP Monitoring** - Check database connections and other TCP services
|
|
14
14
|
- **DNS Monitoring** - Verify DNS records and resolution
|
|
15
15
|
- **Global Regions** - Monitor from 28 locations worldwide
|
|
16
|
-
- **Type-safe** - Full TypeScript support with generated types
|
|
16
|
+
- **Type-safe** - Full TypeScript support with generated types from protobuf
|
|
17
17
|
|
|
18
18
|
## Installation
|
|
19
19
|
|
|
20
20
|
### JSR
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
npx jsr add @openstatus/node
|
|
23
|
+
npx jsr add @openstatus/sdk-node
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### npm
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
npm install @openstatus/node
|
|
29
|
+
npm install @openstatus/sdk-node
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
### Deno
|
|
33
33
|
|
|
34
34
|
```typescript
|
|
35
|
-
import { openstatus } from "jsr:@openstatus/node
|
|
35
|
+
import { openstatus } from "jsr:@openstatus/sdk-node";
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
## Quick Start
|
|
39
39
|
|
|
40
40
|
```typescript
|
|
41
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
openstatus,
|
|
43
|
+
Periodicity,
|
|
44
|
+
Region,
|
|
45
|
+
HTTPMethod,
|
|
46
|
+
NumberComparator,
|
|
47
|
+
} from "@openstatus/sdk-node";
|
|
42
48
|
|
|
43
49
|
const headers = {
|
|
44
|
-
"x-openstatus-key":
|
|
50
|
+
"x-openstatus-key": `${process.env.OPENSTATUS_API_KEY}`,
|
|
45
51
|
};
|
|
46
52
|
|
|
47
53
|
// Create a monitor
|
|
48
|
-
const monitor = await openstatus.monitor.v1.MonitorService.createHTTPMonitor(
|
|
54
|
+
const { monitor } = await openstatus.monitor.v1.MonitorService.createHTTPMonitor(
|
|
49
55
|
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
monitor: {
|
|
57
|
+
name: "My API",
|
|
58
|
+
url: "https://api.example.com/health",
|
|
59
|
+
periodicity: Periodicity.PERIODICITY_1M,
|
|
60
|
+
method: HTTPMethod.HTTP_METHOD_GET,
|
|
61
|
+
regions: [Region.FLY_AMS, Region.FLY_IAD, Region.FLY_SYD],
|
|
62
|
+
active: true,
|
|
63
|
+
statusCodeAssertions: [
|
|
64
|
+
{ comparator: NumberComparator.EQUAL, target: BigInt(200) },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
57
67
|
},
|
|
58
68
|
{ headers },
|
|
59
69
|
);
|
|
60
70
|
|
|
61
|
-
console.log(`Monitor created: ${monitor
|
|
71
|
+
console.log(`Monitor created: ${monitor?.id}`);
|
|
62
72
|
|
|
63
73
|
// List all monitors
|
|
64
74
|
const { httpMonitors, tcpMonitors, dnsMonitors, totalSize } =
|
|
@@ -74,7 +84,7 @@ All API requests require an API key. Get yours from the
|
|
|
74
84
|
|
|
75
85
|
```typescript
|
|
76
86
|
const headers = {
|
|
77
|
-
"x-openstatus-key":
|
|
87
|
+
"x-openstatus-key": `${process.env.OPENSTATUS_API_KEY}`,
|
|
78
88
|
};
|
|
79
89
|
|
|
80
90
|
// Pass headers to any service method
|
|
@@ -97,18 +107,38 @@ await openstatus.monitor.v1.MonitorService.listMonitors({}, { headers });
|
|
|
97
107
|
Create an HTTP/HTTPS monitor.
|
|
98
108
|
|
|
99
109
|
```typescript
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
import { Periodicity, Region, HTTPMethod } from "@openstatus/sdk-node";
|
|
111
|
+
|
|
112
|
+
const { monitor } = await openstatus.monitor.v1.MonitorService.createHTTPMonitor(
|
|
113
|
+
{
|
|
114
|
+
monitor: {
|
|
103
115
|
name: "My Website",
|
|
104
116
|
url: "https://example.com",
|
|
105
|
-
periodicity:
|
|
106
|
-
method:
|
|
107
|
-
regions: [
|
|
117
|
+
periodicity: Periodicity.PERIODICITY_1M,
|
|
118
|
+
method: HTTPMethod.HTTP_METHOD_GET,
|
|
119
|
+
regions: [Region.FLY_AMS, Region.FLY_IAD, Region.FLY_SYD],
|
|
108
120
|
active: true,
|
|
109
121
|
},
|
|
110
|
-
|
|
111
|
-
|
|
122
|
+
},
|
|
123
|
+
{ headers },
|
|
124
|
+
);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### `updateHTTPMonitor(request, options)`
|
|
128
|
+
|
|
129
|
+
Update an existing HTTP monitor.
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
const { monitor } = await openstatus.monitor.v1.MonitorService.updateHTTPMonitor(
|
|
133
|
+
{
|
|
134
|
+
id: "mon_123",
|
|
135
|
+
monitor: {
|
|
136
|
+
name: "Updated Name",
|
|
137
|
+
active: false,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{ headers },
|
|
141
|
+
);
|
|
112
142
|
```
|
|
113
143
|
|
|
114
144
|
#### `createTCPMonitor(request, options)`
|
|
@@ -118,11 +148,29 @@ Create a TCP connection monitor.
|
|
|
118
148
|
```typescript
|
|
119
149
|
const { monitor } = await openstatus.monitor.v1.MonitorService.createTCPMonitor(
|
|
120
150
|
{
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
151
|
+
monitor: {
|
|
152
|
+
name: "Database",
|
|
153
|
+
uri: "db.example.com:5432",
|
|
154
|
+
periodicity: Periodicity.PERIODICITY_5M,
|
|
155
|
+
regions: [Region.FLY_AMS, Region.FLY_IAD],
|
|
156
|
+
active: true,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{ headers },
|
|
160
|
+
);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### `updateTCPMonitor(request, options)`
|
|
164
|
+
|
|
165
|
+
Update an existing TCP monitor.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
const { monitor } = await openstatus.monitor.v1.MonitorService.updateTCPMonitor(
|
|
169
|
+
{
|
|
170
|
+
id: "mon_123",
|
|
171
|
+
monitor: {
|
|
172
|
+
name: "Updated Database Monitor",
|
|
173
|
+
},
|
|
126
174
|
},
|
|
127
175
|
{ headers },
|
|
128
176
|
);
|
|
@@ -133,18 +181,40 @@ const { monitor } = await openstatus.monitor.v1.MonitorService.createTCPMonitor(
|
|
|
133
181
|
Create a DNS resolution monitor.
|
|
134
182
|
|
|
135
183
|
```typescript
|
|
184
|
+
import { RecordComparator } from "@openstatus/sdk-node";
|
|
185
|
+
|
|
136
186
|
const { monitor } = await openstatus.monitor.v1.MonitorService.createDNSMonitor(
|
|
137
187
|
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
188
|
+
monitor: {
|
|
189
|
+
name: "DNS Check",
|
|
190
|
+
uri: "example.com",
|
|
191
|
+
periodicity: Periodicity.PERIODICITY_10M,
|
|
192
|
+
regions: [Region.FLY_AMS],
|
|
193
|
+
active: true,
|
|
194
|
+
recordAssertions: [
|
|
195
|
+
{
|
|
196
|
+
record: "A",
|
|
197
|
+
comparator: RecordComparator.EQUAL,
|
|
198
|
+
target: "93.184.216.34",
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{ headers },
|
|
204
|
+
);
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### `updateDNSMonitor(request, options)`
|
|
208
|
+
|
|
209
|
+
Update an existing DNS monitor.
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
const { monitor } = await openstatus.monitor.v1.MonitorService.updateDNSMonitor(
|
|
213
|
+
{
|
|
214
|
+
id: "mon_123",
|
|
215
|
+
monitor: {
|
|
216
|
+
name: "Updated DNS Check",
|
|
217
|
+
},
|
|
148
218
|
},
|
|
149
219
|
{ headers },
|
|
150
220
|
);
|
|
@@ -167,7 +237,7 @@ const { httpMonitors, tcpMonitors, dnsMonitors, nextPageToken, totalSize } =
|
|
|
167
237
|
Trigger an immediate check.
|
|
168
238
|
|
|
169
239
|
```typescript
|
|
170
|
-
await openstatus.monitor.v1.MonitorService.triggerMonitor(
|
|
240
|
+
const { success } = await openstatus.monitor.v1.MonitorService.triggerMonitor(
|
|
171
241
|
{ id: "mon_123" },
|
|
172
242
|
{ headers },
|
|
173
243
|
);
|
|
@@ -178,7 +248,7 @@ await openstatus.monitor.v1.MonitorService.triggerMonitor(
|
|
|
178
248
|
Delete a monitor.
|
|
179
249
|
|
|
180
250
|
```typescript
|
|
181
|
-
await openstatus.monitor.v1.MonitorService.deleteMonitor(
|
|
251
|
+
const { success } = await openstatus.monitor.v1.MonitorService.deleteMonitor(
|
|
182
252
|
{ id: "mon_123" },
|
|
183
253
|
{ headers },
|
|
184
254
|
);
|
|
@@ -189,16 +259,18 @@ await openstatus.monitor.v1.MonitorService.deleteMonitor(
|
|
|
189
259
|
Get the current status of a monitor across all configured regions.
|
|
190
260
|
|
|
191
261
|
```typescript
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
262
|
+
import { MonitorStatus, Region } from "@openstatus/sdk-node";
|
|
263
|
+
|
|
264
|
+
const { id, regions } = await openstatus.monitor.v1.MonitorService.getMonitorStatus(
|
|
265
|
+
{ id: "mon_123" },
|
|
266
|
+
{ headers },
|
|
267
|
+
);
|
|
197
268
|
|
|
198
269
|
// regions is an array of { region, status }
|
|
199
|
-
//
|
|
270
|
+
// region: Region enum value (e.g., Region.FLY_AMS)
|
|
271
|
+
// status: MonitorStatus.ACTIVE, MonitorStatus.DEGRADED, or MonitorStatus.ERROR
|
|
200
272
|
for (const { region, status } of regions) {
|
|
201
|
-
console.log(`${region}: ${status}`);
|
|
273
|
+
console.log(`${Region[region]}: ${MonitorStatus[status]}`);
|
|
202
274
|
}
|
|
203
275
|
```
|
|
204
276
|
|
|
@@ -207,12 +279,12 @@ for (const { region, status } of regions) {
|
|
|
207
279
|
Get aggregated metrics and latency percentiles for a monitor.
|
|
208
280
|
|
|
209
281
|
```typescript
|
|
210
|
-
import { TimeRange } from "@openstatus/node
|
|
282
|
+
import { TimeRange } from "@openstatus/sdk-node";
|
|
211
283
|
|
|
212
284
|
const summary = await openstatus.monitor.v1.MonitorService.getMonitorSummary(
|
|
213
285
|
{
|
|
214
286
|
id: "mon_123",
|
|
215
|
-
timeRange: TimeRange.TIME_RANGE_7D, //
|
|
287
|
+
timeRange: TimeRange.TIME_RANGE_7D, // TIME_RANGE_1D, TIME_RANGE_7D, or TIME_RANGE_14D
|
|
216
288
|
regions: [], // optional: filter by specific regions
|
|
217
289
|
},
|
|
218
290
|
{ headers },
|
|
@@ -223,6 +295,8 @@ console.log(`Success: ${summary.totalSuccessful}`);
|
|
|
223
295
|
console.log(`Degraded: ${summary.totalDegraded}`);
|
|
224
296
|
console.log(`Failed: ${summary.totalFailed}`);
|
|
225
297
|
console.log(`P50 latency: ${summary.p50}ms`);
|
|
298
|
+
console.log(`P75 latency: ${summary.p75}ms`);
|
|
299
|
+
console.log(`P90 latency: ${summary.p90}ms`);
|
|
226
300
|
console.log(`P95 latency: ${summary.p95}ms`);
|
|
227
301
|
console.log(`P99 latency: ${summary.p99}ms`);
|
|
228
302
|
```
|
|
@@ -232,155 +306,252 @@ console.log(`P99 latency: ${summary.p99}ms`);
|
|
|
232
306
|
Check API health status (no authentication required).
|
|
233
307
|
|
|
234
308
|
```typescript
|
|
309
|
+
import { ServingStatus } from "@openstatus/sdk-node";
|
|
310
|
+
|
|
235
311
|
const { status } = await openstatus.health.v1.HealthService.check({});
|
|
236
|
-
console.log(status); // "SERVING"
|
|
312
|
+
console.log(ServingStatus[status]); // "SERVING"
|
|
237
313
|
```
|
|
238
314
|
|
|
239
315
|
## Monitor Options
|
|
240
316
|
|
|
241
317
|
### HTTP Monitor
|
|
242
318
|
|
|
243
|
-
| Option | Type
|
|
244
|
-
| ---------------------- |
|
|
245
|
-
| `name` | string
|
|
246
|
-
| `url` | string
|
|
247
|
-
| `periodicity` |
|
|
248
|
-
| `method` |
|
|
249
|
-
| `body` | string
|
|
250
|
-
| `headers` |
|
|
251
|
-
| `timeout` |
|
|
252
|
-
| `retry` |
|
|
253
|
-
| `followRedirects` | boolean
|
|
254
|
-
| `regions` |
|
|
255
|
-
| `active` | boolean
|
|
256
|
-
| `public` | boolean
|
|
257
|
-
| `degradedAt` |
|
|
258
|
-
| `
|
|
259
|
-
| `
|
|
260
|
-
| `
|
|
319
|
+
| Option | Type | Required | Description |
|
|
320
|
+
| ---------------------- | ------------------ | -------- | -------------------------------------------------------- |
|
|
321
|
+
| `name` | string | Yes | Monitor name (max 256 chars) |
|
|
322
|
+
| `url` | string | Yes | URL to monitor (max 2048 chars) |
|
|
323
|
+
| `periodicity` | Periodicity | Yes | Check interval (see [Periodicity](#periodicity)) |
|
|
324
|
+
| `method` | HTTPMethod | No | HTTP method (see [HTTP Methods](#http-methods)) |
|
|
325
|
+
| `body` | string | No | Request body |
|
|
326
|
+
| `headers` | Headers[] | No | Custom headers (`{ key: string, value: string }[]`) |
|
|
327
|
+
| `timeout` | bigint | No | Timeout in ms (default: 45000, max: 120000) |
|
|
328
|
+
| `retry` | bigint | No | Retry attempts (default: 3, max: 10) |
|
|
329
|
+
| `followRedirects` | boolean | No | Follow redirects (default: true) |
|
|
330
|
+
| `regions` | Region[] | No | [Regions](#regions) for checks |
|
|
331
|
+
| `active` | boolean | No | Enable monitoring (default: false) |
|
|
332
|
+
| `public` | boolean | No | Public visibility (default: false) |
|
|
333
|
+
| `degradedAt` | bigint | No | Latency threshold (ms) for degraded status |
|
|
334
|
+
| `description` | string | No | Monitor description (max 1024 chars) |
|
|
335
|
+
| `statusCodeAssertions` | array | No | [Status code assertions](#status-code-assertions) |
|
|
336
|
+
| `bodyAssertions` | array | No | [Body assertions](#body-assertions) |
|
|
337
|
+
| `headerAssertions` | array | No | [Header assertions](#header-assertions) |
|
|
338
|
+
| `openTelemetry` | OpenTelemetryConfig| No | OpenTelemetry export configuration |
|
|
261
339
|
|
|
262
340
|
### TCP Monitor
|
|
263
341
|
|
|
264
|
-
| Option
|
|
265
|
-
|
|
|
266
|
-
| `name`
|
|
267
|
-
| `uri`
|
|
268
|
-
| `periodicity`
|
|
269
|
-
| `timeout`
|
|
270
|
-
| `retry`
|
|
271
|
-
| `regions`
|
|
272
|
-
| `active`
|
|
342
|
+
| Option | Type | Required | Description |
|
|
343
|
+
| --------------- | ------------------ | -------- | ------------------------------------------------ |
|
|
344
|
+
| `name` | string | Yes | Monitor name (max 256 chars) |
|
|
345
|
+
| `uri` | string | Yes | `host:port` to monitor (max 2048 chars) |
|
|
346
|
+
| `periodicity` | Periodicity | Yes | Check interval (see [Periodicity](#periodicity)) |
|
|
347
|
+
| `timeout` | bigint | No | Timeout in ms (default: 45000, max: 120000) |
|
|
348
|
+
| `retry` | bigint | No | Retry attempts (default: 3, max: 10) |
|
|
349
|
+
| `regions` | Region[] | No | [Regions](#regions) for checks |
|
|
350
|
+
| `active` | boolean | No | Enable monitoring (default: false) |
|
|
351
|
+
| `public` | boolean | No | Public visibility (default: false) |
|
|
352
|
+
| `degradedAt` | bigint | No | Latency threshold (ms) for degraded status |
|
|
353
|
+
| `description` | string | No | Monitor description (max 1024 chars) |
|
|
354
|
+
| `openTelemetry` | OpenTelemetryConfig| No | OpenTelemetry export configuration |
|
|
273
355
|
|
|
274
356
|
### DNS Monitor
|
|
275
357
|
|
|
276
|
-
| Option | Type
|
|
277
|
-
| ------------------ |
|
|
278
|
-
| `name` | string
|
|
279
|
-
| `uri` | string
|
|
280
|
-
| `periodicity` |
|
|
281
|
-
| `timeout` |
|
|
282
|
-
| `retry` |
|
|
283
|
-
| `regions` |
|
|
284
|
-
| `
|
|
358
|
+
| Option | Type | Required | Description |
|
|
359
|
+
| ------------------ | ------------------ | -------- | -------------------------------------------------- |
|
|
360
|
+
| `name` | string | Yes | Monitor name (max 256 chars) |
|
|
361
|
+
| `uri` | string | Yes | Domain to resolve (max 2048 chars) |
|
|
362
|
+
| `periodicity` | Periodicity | Yes | Check interval (see [Periodicity](#periodicity)) |
|
|
363
|
+
| `timeout` | bigint | No | Timeout in ms (default: 45000, max: 120000) |
|
|
364
|
+
| `retry` | bigint | No | Retry attempts (default: 3, max: 10) |
|
|
365
|
+
| `regions` | Region[] | No | [Regions](#regions) for checks |
|
|
366
|
+
| `active` | boolean | No | Enable monitoring (default: false) |
|
|
367
|
+
| `public` | boolean | No | Public visibility (default: false) |
|
|
368
|
+
| `degradedAt` | bigint | No | Latency threshold (ms) for degraded status |
|
|
369
|
+
| `description` | string | No | Monitor description (max 1024 chars) |
|
|
370
|
+
| `recordAssertions` | array | No | [DNS record assertions](#dns-record-assertions) |
|
|
371
|
+
| `openTelemetry` | OpenTelemetryConfig| No | OpenTelemetry export configuration |
|
|
372
|
+
|
|
373
|
+
### Periodicity
|
|
374
|
+
|
|
375
|
+
| Enum Value | Description |
|
|
376
|
+
| ----------------------- | ------------ |
|
|
377
|
+
| `PERIODICITY_30S` | Every 30s |
|
|
378
|
+
| `PERIODICITY_1M` | Every 1m |
|
|
379
|
+
| `PERIODICITY_5M` | Every 5m |
|
|
380
|
+
| `PERIODICITY_10M` | Every 10m |
|
|
381
|
+
| `PERIODICITY_30M` | Every 30m |
|
|
382
|
+
| `PERIODICITY_1H` | Every 1h |
|
|
383
|
+
|
|
384
|
+
### HTTP Methods
|
|
385
|
+
|
|
386
|
+
| Enum Value | Description |
|
|
387
|
+
| ------------------------- | ----------- |
|
|
388
|
+
| `HTTP_METHOD_GET` | GET |
|
|
389
|
+
| `HTTP_METHOD_POST` | POST |
|
|
390
|
+
| `HTTP_METHOD_HEAD` | HEAD |
|
|
391
|
+
| `HTTP_METHOD_PUT` | PUT |
|
|
392
|
+
| `HTTP_METHOD_PATCH` | PATCH |
|
|
393
|
+
| `HTTP_METHOD_DELETE` | DELETE |
|
|
394
|
+
| `HTTP_METHOD_TRACE` | TRACE |
|
|
395
|
+
| `HTTP_METHOD_CONNECT` | CONNECT |
|
|
396
|
+
| `HTTP_METHOD_OPTIONS` | OPTIONS |
|
|
285
397
|
|
|
286
398
|
## Assertions
|
|
287
399
|
|
|
400
|
+
All assertion comparators are exported as enums from the SDK.
|
|
401
|
+
|
|
288
402
|
### Status Code Assertions
|
|
289
403
|
|
|
290
|
-
Validate HTTP response status codes
|
|
404
|
+
Validate HTTP response status codes using `NumberComparator`.
|
|
291
405
|
|
|
292
406
|
```typescript
|
|
407
|
+
import { NumberComparator } from "@openstatus/sdk-node";
|
|
408
|
+
|
|
293
409
|
{
|
|
294
410
|
statusCodeAssertions: [
|
|
295
|
-
{ comparator:
|
|
296
|
-
{ comparator:
|
|
411
|
+
{ comparator: NumberComparator.EQUAL, target: BigInt(200) },
|
|
412
|
+
{ comparator: NumberComparator.LESS_THAN, target: BigInt(400) },
|
|
297
413
|
];
|
|
298
414
|
}
|
|
299
415
|
```
|
|
300
416
|
|
|
301
|
-
**
|
|
302
|
-
|
|
417
|
+
**NumberComparator values:**
|
|
418
|
+
|
|
419
|
+
| Enum Value | Description |
|
|
420
|
+
| ----------------------- | ------------------------ |
|
|
421
|
+
| `EQUAL` | Equal to target |
|
|
422
|
+
| `NOT_EQUAL` | Not equal to target |
|
|
423
|
+
| `GREATER_THAN` | Greater than target |
|
|
424
|
+
| `GREATER_THAN_OR_EQUAL` | Greater than or equal |
|
|
425
|
+
| `LESS_THAN` | Less than target |
|
|
426
|
+
| `LESS_THAN_OR_EQUAL` | Less than or equal |
|
|
303
427
|
|
|
304
428
|
### Body Assertions
|
|
305
429
|
|
|
306
|
-
Validate response body content
|
|
430
|
+
Validate response body content using `StringComparator`.
|
|
307
431
|
|
|
308
432
|
```typescript
|
|
433
|
+
import { StringComparator } from "@openstatus/sdk-node";
|
|
434
|
+
|
|
309
435
|
{
|
|
310
436
|
bodyAssertions: [
|
|
311
|
-
{ comparator:
|
|
312
|
-
{ comparator:
|
|
437
|
+
{ comparator: StringComparator.CONTAINS, target: '"status":"ok"' },
|
|
438
|
+
{ comparator: StringComparator.NOT_EMPTY, target: "" },
|
|
313
439
|
];
|
|
314
440
|
}
|
|
315
441
|
```
|
|
316
442
|
|
|
317
|
-
**
|
|
318
|
-
|
|
443
|
+
**StringComparator values:**
|
|
444
|
+
|
|
445
|
+
| Enum Value | Description |
|
|
446
|
+
| ----------------------- | ---------------------------- |
|
|
447
|
+
| `CONTAINS` | Contains target string |
|
|
448
|
+
| `NOT_CONTAINS` | Does not contain target |
|
|
449
|
+
| `EQUAL` | Equal to target |
|
|
450
|
+
| `NOT_EQUAL` | Not equal to target |
|
|
451
|
+
| `EMPTY` | Body is empty |
|
|
452
|
+
| `NOT_EMPTY` | Body is not empty |
|
|
453
|
+
| `GREATER_THAN` | Lexicographically greater |
|
|
454
|
+
| `GREATER_THAN_OR_EQUAL` | Lexicographically >= target |
|
|
455
|
+
| `LESS_THAN` | Lexicographically less |
|
|
456
|
+
| `LESS_THAN_OR_EQUAL` | Lexicographically <= target |
|
|
319
457
|
|
|
320
458
|
### Header Assertions
|
|
321
459
|
|
|
322
|
-
Validate response headers
|
|
460
|
+
Validate response headers using `StringComparator`.
|
|
323
461
|
|
|
324
462
|
```typescript
|
|
463
|
+
import { StringComparator } from "@openstatus/sdk-node";
|
|
464
|
+
|
|
325
465
|
{
|
|
326
466
|
headerAssertions: [
|
|
327
|
-
{
|
|
467
|
+
{
|
|
468
|
+
key: "content-type",
|
|
469
|
+
comparator: StringComparator.CONTAINS,
|
|
470
|
+
target: "application/json",
|
|
471
|
+
},
|
|
328
472
|
];
|
|
329
473
|
}
|
|
330
474
|
```
|
|
331
475
|
|
|
332
476
|
### DNS Record Assertions
|
|
333
477
|
|
|
334
|
-
Validate DNS records
|
|
478
|
+
Validate DNS records using `RecordComparator`.
|
|
335
479
|
|
|
336
480
|
```typescript
|
|
481
|
+
import { RecordComparator } from "@openstatus/sdk-node";
|
|
482
|
+
|
|
337
483
|
{
|
|
338
484
|
recordAssertions: [
|
|
339
|
-
{
|
|
340
|
-
{
|
|
485
|
+
{ record: "A", comparator: RecordComparator.EQUAL, target: "93.184.216.34" },
|
|
486
|
+
{ record: "CNAME", comparator: RecordComparator.CONTAINS, target: "cdn" },
|
|
341
487
|
];
|
|
342
488
|
}
|
|
343
489
|
```
|
|
344
490
|
|
|
345
|
-
**
|
|
491
|
+
**RecordComparator values:**
|
|
492
|
+
|
|
493
|
+
| Enum Value | Description |
|
|
494
|
+
| -------------- | ----------------------- |
|
|
495
|
+
| `EQUAL` | Equal to target |
|
|
496
|
+
| `NOT_EQUAL` | Not equal to target |
|
|
497
|
+
| `CONTAINS` | Contains target string |
|
|
498
|
+
| `NOT_CONTAINS` | Does not contain target |
|
|
499
|
+
|
|
500
|
+
**Supported record types:** `A`, `AAAA`, `CNAME`, `MX`, `TXT`
|
|
346
501
|
|
|
347
502
|
## Regions
|
|
348
503
|
|
|
349
|
-
Monitor from 28 global locations across multiple providers:
|
|
504
|
+
Monitor from 28 global locations across multiple providers. Use the `Region` enum:
|
|
505
|
+
|
|
506
|
+
```typescript
|
|
507
|
+
import { Region } from "@openstatus/sdk-node";
|
|
508
|
+
|
|
509
|
+
// Example: Use specific regions
|
|
510
|
+
regions: [Region.FLY_AMS, Region.FLY_IAD, Region.KOYEB_FRA];
|
|
511
|
+
```
|
|
350
512
|
|
|
351
513
|
### Fly.io Regions
|
|
352
514
|
|
|
353
|
-
|
|
|
354
|
-
|
|
|
355
|
-
| `
|
|
356
|
-
| `
|
|
357
|
-
| `
|
|
358
|
-
| `
|
|
359
|
-
| `
|
|
360
|
-
| `
|
|
361
|
-
| `
|
|
362
|
-
| `
|
|
363
|
-
| `
|
|
515
|
+
| Enum Value | Location |
|
|
516
|
+
| ---------- | --------------- |
|
|
517
|
+
| `FLY_AMS` | Amsterdam |
|
|
518
|
+
| `FLY_ARN` | Stockholm |
|
|
519
|
+
| `FLY_BOM` | Mumbai |
|
|
520
|
+
| `FLY_CDG` | Paris |
|
|
521
|
+
| `FLY_DFW` | Dallas |
|
|
522
|
+
| `FLY_EWR` | Newark |
|
|
523
|
+
| `FLY_FRA` | Frankfurt |
|
|
524
|
+
| `FLY_GRU` | São Paulo |
|
|
525
|
+
| `FLY_IAD` | Washington D.C. |
|
|
526
|
+
| `FLY_JNB` | Johannesburg |
|
|
527
|
+
| `FLY_LAX` | Los Angeles |
|
|
528
|
+
| `FLY_LHR` | London |
|
|
529
|
+
| `FLY_NRT` | Tokyo |
|
|
530
|
+
| `FLY_ORD` | Chicago |
|
|
531
|
+
| `FLY_SJC` | San Jose |
|
|
532
|
+
| `FLY_SIN` | Singapore |
|
|
533
|
+
| `FLY_SYD` | Sydney |
|
|
534
|
+
| `FLY_YYZ` | Toronto |
|
|
364
535
|
|
|
365
536
|
### Koyeb Regions
|
|
366
537
|
|
|
367
|
-
|
|
|
538
|
+
| Enum Value | Location |
|
|
368
539
|
| ----------- | ------------- |
|
|
369
|
-
| `
|
|
370
|
-
| `
|
|
371
|
-
| `
|
|
372
|
-
| `
|
|
373
|
-
| `
|
|
374
|
-
| `
|
|
540
|
+
| `KOYEB_FRA` | Frankfurt |
|
|
541
|
+
| `KOYEB_PAR` | Paris |
|
|
542
|
+
| `KOYEB_SFO` | San Francisco |
|
|
543
|
+
| `KOYEB_SIN` | Singapore |
|
|
544
|
+
| `KOYEB_TYO` | Tokyo |
|
|
545
|
+
| `KOYEB_WAS` | Washington |
|
|
375
546
|
|
|
376
547
|
### Railway Regions
|
|
377
548
|
|
|
378
|
-
|
|
|
379
|
-
|
|
|
380
|
-
| `
|
|
381
|
-
| `
|
|
382
|
-
| `
|
|
383
|
-
| `
|
|
549
|
+
| Enum Value | Location |
|
|
550
|
+
| ------------------------ | -------------- |
|
|
551
|
+
| `RAILWAY_US_WEST2` | US West |
|
|
552
|
+
| `RAILWAY_US_EAST4` | US East |
|
|
553
|
+
| `RAILWAY_EUROPE_WEST4` | Europe West |
|
|
554
|
+
| `RAILWAY_ASIA_SOUTHEAST1`| Asia Southeast |
|
|
384
555
|
|
|
385
556
|
## Error Handling
|
|
386
557
|
|