@openstatus/health-resend 0.1.4-dev.0

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 ADDED
@@ -0,0 +1,72 @@
1
+ # @openstatus/health-resend
2
+
3
+ [Resend](https://resend.com/) probe for
4
+ [`@openstatus/health`](https://jsr.io/@openstatus/health). Sends
5
+ `GET {baseUrl}/domains` with your API key as a bearer header, so it proves
6
+ both that the Resend API answers and that the key is valid — with `fetch`
7
+ alone, on every runtime.
8
+
9
+ ```sh
10
+ deno add jsr:@openstatus/health jsr:@openstatus/health-resend
11
+ npm install @openstatus/health @openstatus/health-resend
12
+ ```
13
+
14
+ ```ts
15
+ import { createHealthHandler, readEnv } from "@openstatus/health";
16
+ import { resendProbe } from "@openstatus/health-resend";
17
+
18
+ const apiKey = readEnv("RESEND_API_KEY");
19
+
20
+ Deno.serve(
21
+ createHealthHandler({
22
+ probes: [
23
+ // the factory validates `apiKey` at construction, so pass a
24
+ // placeholder and let `skip` keep the unconfigured check from running.
25
+ resendProbe({
26
+ apiKey: apiKey || "unconfigured",
27
+ skip: () => !apiKey,
28
+ }),
29
+ ],
30
+ }),
31
+ );
32
+ ```
33
+
34
+ `apiKey` is the `re_…` key from the Resend dashboard. Listing domains is a
35
+ read with no side effects — it sends no email and counts against no sending
36
+ quota — so the probe can run on every health request. `baseUrl` defaults to
37
+ `https://api.resend.com`. Like every probe here, this one never reads the
38
+ environment itself — pass the values in, and use `skip` for environments where
39
+ Resend is not configured.
40
+
41
+ ```ts
42
+ resendProbe({
43
+ apiKey,
44
+ // optional overrides from the Probe contract
45
+ name: "email",
46
+ critical: true,
47
+ timeoutMs: 2000,
48
+ skip: () => !apiKey,
49
+ });
50
+ ```
51
+
52
+ Non-critical by default: email is usually sent after the request completes, so
53
+ an outage degrades the report instead of taking the service out of rotation.
54
+ Set `critical: true` when a request cannot succeed without sending.
55
+
56
+ ## About openstatus
57
+
58
+ [openstatus](https://www.openstatus.dev/) is the open-source uptime monitoring
59
+ and status page platform. This package is part of
60
+ [`@openstatus/health`](https://github.com/openstatusHQ/health), the `/health`
61
+ endpoints behind openstatus's own services, extracted so any JavaScript server
62
+ can expose one. Point an
63
+ [openstatus monitor](https://www.openstatus.dev/docs/reference/http-monitor)
64
+ at the endpoint and assert on `status` in the body to be alerted on
65
+ `degraded` before it becomes `unhealthy`.
66
+
67
+ Source: [github.com/openstatusHQ/health](https://github.com/openstatusHQ/health).
68
+ Issues and PRs welcome.
69
+
70
+ ## License
71
+
72
+ [MIT](https://github.com/openstatusHQ/health/blob/main/LICENSE)
@@ -0,0 +1,30 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+
25
+ Object.defineProperty(exports, '__toESM', {
26
+ enumerable: true,
27
+ get: function () {
28
+ return __toESM;
29
+ }
30
+ });
package/dist/mod.cjs ADDED
@@ -0,0 +1,36 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const __openstatus_health = require_rolldown_runtime.__toESM(require("@openstatus/health"));
3
+
4
+ //#region src/mod.ts
5
+ /** API base URL when `baseUrl` is unset. */
6
+ const resendDefaultBaseUrl = "https://api.resend.com";
7
+ /** Probe name when `name` is unset. */
8
+ const resendDefaultName = "resend";
9
+ /** A probe that expects 2xx from `GET {baseUrl}/domains` with `apiKey` as a bearer token; non-critical by default. Throws `ProbeConfigError` for an empty `apiKey` or an invalid `baseUrl`. */
10
+ function resendProbe(options) {
11
+ const doFetch = options.fetch ?? globalThis.fetch;
12
+ const url = (0, __openstatus_health.probeUrl)({
13
+ probe: "resendProbe",
14
+ field: "baseUrl",
15
+ value: options.baseUrl ?? resendDefaultBaseUrl,
16
+ path: "/domains"
17
+ });
18
+ if (typeof options.apiKey !== "string" || options.apiKey.length === 0) throw new __openstatus_health.ProbeConfigError("resendProbe", "apiKey", typeof options.apiKey !== "string" ? `must be a string, got ${String(options.apiKey)}` : "must not be empty");
19
+ const headers = { authorization: `Bearer ${options.apiKey}` };
20
+ return {
21
+ name: options.name ?? resendDefaultName,
22
+ critical: options.critical ?? false,
23
+ timeoutMs: options.timeoutMs,
24
+ skip: options.skip,
25
+ run: (signal) => (0, __openstatus_health.expectOk)(doFetch(url, {
26
+ method: "GET",
27
+ headers,
28
+ signal
29
+ }))
30
+ };
31
+ }
32
+
33
+ //#endregion
34
+ exports.resendDefaultBaseUrl = resendDefaultBaseUrl;
35
+ exports.resendDefaultName = resendDefaultName;
36
+ exports.resendProbe = resendProbe;
package/dist/mod.d.cts ADDED
@@ -0,0 +1,23 @@
1
+ import { Probe, ProbeOverrides } from "@openstatus/health";
2
+
3
+ //#region src/mod.d.ts
4
+
5
+ /** API base URL when `baseUrl` is unset. */
6
+ declare const resendDefaultBaseUrl = "https://api.resend.com";
7
+ /** Probe name when `name` is unset. */
8
+ declare const resendDefaultName = "resend";
9
+ /** Options for `resendProbe()`. */
10
+ interface ResendProbeOptions extends ProbeOverrides {
11
+ /** A Resend API key; full-access or a sending key with domain read access. */
12
+ readonly apiKey: string;
13
+ /** API host. Default `resendDefaultBaseUrl`. */
14
+ readonly baseUrl?: string | URL;
15
+ /** Replacement `fetch`, for tests. */
16
+ readonly fetch?: typeof fetch;
17
+ }
18
+ /** A probe that expects 2xx from `GET {baseUrl}/domains` with `apiKey` as a bearer token; non-critical by default. Throws `ProbeConfigError` for an empty `apiKey` or an invalid `baseUrl`. */
19
+ declare function resendProbe(options: ResendProbeOptions): Probe;
20
+ //# sourceMappingURL=mod.d.ts.map
21
+ //#endregion
22
+ export { ResendProbeOptions, resendDefaultBaseUrl, resendDefaultName, resendProbe };
23
+ //# sourceMappingURL=mod.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAoCqC,cAfxB,oBAAA,GAewB,wBAAA;;AAA0B,cAblD,iBAAA,GAakD,QAAA;;UAV9C,kBAAA,SAA2B;;;;8BAId;;0BAEJ;;;iBAIV,WAAA,UAAqB,qBAAqB"}
package/dist/mod.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { Probe, ProbeOverrides } from "@openstatus/health";
2
+
3
+ //#region src/mod.d.ts
4
+
5
+ /** API base URL when `baseUrl` is unset. */
6
+ declare const resendDefaultBaseUrl = "https://api.resend.com";
7
+ /** Probe name when `name` is unset. */
8
+ declare const resendDefaultName = "resend";
9
+ /** Options for `resendProbe()`. */
10
+ interface ResendProbeOptions extends ProbeOverrides {
11
+ /** A Resend API key; full-access or a sending key with domain read access. */
12
+ readonly apiKey: string;
13
+ /** API host. Default `resendDefaultBaseUrl`. */
14
+ readonly baseUrl?: string | URL;
15
+ /** Replacement `fetch`, for tests. */
16
+ readonly fetch?: typeof fetch;
17
+ }
18
+ /** A probe that expects 2xx from `GET {baseUrl}/domains` with `apiKey` as a bearer token; non-critical by default. Throws `ProbeConfigError` for an empty `apiKey` or an invalid `baseUrl`. */
19
+ declare function resendProbe(options: ResendProbeOptions): Probe;
20
+ //# sourceMappingURL=mod.d.ts.map
21
+ //#endregion
22
+ export { ResendProbeOptions, resendDefaultBaseUrl, resendDefaultName, resendProbe };
23
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAoCqC,cAfxB,oBAAA,GAewB,wBAAA;;AAA0B,cAblD,iBAAA,GAakD,QAAA;;UAV9C,kBAAA,SAA2B;;;;8BAId;;0BAEJ;;;iBAIV,WAAA,UAAqB,qBAAqB"}
package/dist/mod.js ADDED
@@ -0,0 +1,34 @@
1
+ import { ProbeConfigError, expectOk, probeUrl } from "@openstatus/health";
2
+
3
+ //#region src/mod.ts
4
+ /** API base URL when `baseUrl` is unset. */
5
+ const resendDefaultBaseUrl = "https://api.resend.com";
6
+ /** Probe name when `name` is unset. */
7
+ const resendDefaultName = "resend";
8
+ /** A probe that expects 2xx from `GET {baseUrl}/domains` with `apiKey` as a bearer token; non-critical by default. Throws `ProbeConfigError` for an empty `apiKey` or an invalid `baseUrl`. */
9
+ function resendProbe(options) {
10
+ const doFetch = options.fetch ?? globalThis.fetch;
11
+ const url = probeUrl({
12
+ probe: "resendProbe",
13
+ field: "baseUrl",
14
+ value: options.baseUrl ?? resendDefaultBaseUrl,
15
+ path: "/domains"
16
+ });
17
+ if (typeof options.apiKey !== "string" || options.apiKey.length === 0) throw new ProbeConfigError("resendProbe", "apiKey", typeof options.apiKey !== "string" ? `must be a string, got ${String(options.apiKey)}` : "must not be empty");
18
+ const headers = { authorization: `Bearer ${options.apiKey}` };
19
+ return {
20
+ name: options.name ?? resendDefaultName,
21
+ critical: options.critical ?? false,
22
+ timeoutMs: options.timeoutMs,
23
+ skip: options.skip,
24
+ run: (signal) => expectOk(doFetch(url, {
25
+ method: "GET",
26
+ headers,
27
+ signal
28
+ }))
29
+ };
30
+ }
31
+
32
+ //#endregion
33
+ export { resendDefaultBaseUrl, resendDefaultName, resendProbe };
34
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","names":["options: ResendProbeOptions"],"sources":["../src/mod.ts"],"sourcesContent":["/**\n * Resend reachability probe for `@openstatus/health`, against `/domains`.\n *\n * ```ts\n * import { resendProbe } from \"@openstatus/health-resend\";\n *\n * const probe = resendProbe({ apiKey: env.RESEND_API_KEY });\n * ```\n *\n * @module\n */\n\nimport {\n expectOk,\n type Probe,\n ProbeConfigError,\n type ProbeOverrides,\n probeUrl,\n} from \"@openstatus/health\";\n\n/** API base URL when `baseUrl` is unset. */\nexport const resendDefaultBaseUrl = \"https://api.resend.com\";\n/** Probe name when `name` is unset. */\nexport const resendDefaultName = \"resend\";\n\n/** Options for `resendProbe()`. */\nexport interface ResendProbeOptions extends ProbeOverrides {\n /** A Resend API key; full-access or a sending key with domain read access. */\n readonly apiKey: string;\n /** API host. Default `resendDefaultBaseUrl`. */\n readonly baseUrl?: string | URL;\n /** Replacement `fetch`, for tests. */\n readonly fetch?: typeof fetch;\n}\n\n/** A probe that expects 2xx from `GET {baseUrl}/domains` with `apiKey` as a bearer token; non-critical by default. Throws `ProbeConfigError` for an empty `apiKey` or an invalid `baseUrl`. */\nexport function resendProbe(options: ResendProbeOptions): Probe {\n const doFetch = options.fetch ?? globalThis.fetch;\n const url = probeUrl({\n probe: \"resendProbe\",\n field: \"baseUrl\",\n value: options.baseUrl ?? resendDefaultBaseUrl,\n path: \"/domains\",\n });\n if (typeof options.apiKey !== \"string\" || options.apiKey.length === 0) {\n throw new ProbeConfigError(\n \"resendProbe\",\n \"apiKey\",\n typeof options.apiKey !== \"string\"\n ? `must be a string, got ${String(options.apiKey)}`\n : \"must not be empty\",\n );\n }\n const headers = { authorization: `Bearer ${options.apiKey}` };\n return {\n name: options.name ?? resendDefaultName,\n critical: options.critical ?? false,\n timeoutMs: options.timeoutMs,\n skip: options.skip,\n run: (signal) => expectOk(doFetch(url, { method: \"GET\", headers, signal })),\n };\n}\n"],"mappings":";;;;AAqBA,MAAa,uBAAuB;;AAEpC,MAAa,oBAAoB;;AAajC,SAAgB,YAAYA,SAAoC;CAC9D,MAAM,UAAU,QAAQ,SAAS,WAAW;CAC5C,MAAM,MAAM,SAAS;EACnB,OAAO;EACP,OAAO;EACP,OAAO,QAAQ,WAAW;EAC1B,MAAM;CACP,EAAC;AACF,YAAW,QAAQ,WAAW,YAAY,QAAQ,OAAO,WAAW,EAClE,OAAM,IAAI,iBACR,eACA,iBACO,QAAQ,WAAW,YACrB,wBAAwB,OAAO,QAAQ,OAAO,CAAC,IAChD;CAGR,MAAM,UAAU,EAAE,gBAAgB,SAAS,QAAQ,OAAO,EAAG;AAC7D,QAAO;EACL,MAAM,QAAQ,QAAQ;EACtB,UAAU,QAAQ,YAAY;EAC9B,WAAW,QAAQ;EACnB,MAAM,QAAQ;EACd,KAAK,CAAC,WAAW,SAAS,QAAQ,KAAK;GAAE,QAAQ;GAAO;GAAS;EAAQ,EAAC,CAAC;CAC5E;AACF"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@openstatus/health-resend",
3
+ "version": "0.1.4-dev.0",
4
+ "description": "Resend API probe for @openstatus/health",
5
+ "keywords": [
6
+ "openstatus",
7
+ "health",
8
+ "healthcheck",
9
+ "resend",
10
+ "email",
11
+ "transactional-email"
12
+ ],
13
+ "license": "MIT",
14
+ "author": {
15
+ "name": "openstatus",
16
+ "url": "https://www.openstatus.dev/"
17
+ },
18
+ "homepage": "https://github.com/openstatusHQ/health",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/openstatusHQ/health.git",
22
+ "directory": "packages/resend/"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/openstatusHQ/health/issues"
26
+ },
27
+ "type": "module",
28
+ "module": "./dist/mod.js",
29
+ "main": "./dist/mod.cjs",
30
+ "types": "./dist/mod.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": {
34
+ "import": "./dist/mod.d.ts",
35
+ "require": "./dist/mod.d.cts"
36
+ },
37
+ "import": "./dist/mod.js",
38
+ "require": "./dist/mod.cjs"
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
42
+ "sideEffects": false,
43
+ "files": [
44
+ "dist/"
45
+ ],
46
+ "engines": {
47
+ "node": ">=22"
48
+ },
49
+ "peerDependencies": {
50
+ "@openstatus/health": "^0.1.4-dev.0"
51
+ },
52
+ "devDependencies": {
53
+ "tsdown": "^0.12.7",
54
+ "typescript": "^5.8.3"
55
+ },
56
+ "scripts": {
57
+ "build": "tsdown",
58
+ "prepack": "tsdown",
59
+ "test": "node --experimental-transform-types --test"
60
+ }
61
+ }