brrr.now 1.0.0 → 1.1.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.
Files changed (2) hide show
  1. package/README.md +21 -17
  2. package/package.json +69 -69
package/README.md CHANGED
@@ -17,13 +17,15 @@ npm install brrr.now
17
17
  ```typescript
18
18
  import { sendNotification } from "brrr.now";
19
19
 
20
- await sendNotification({
21
- webhook: process.env.BRRR_WEBHOOK!,
22
- title: "Coffee Machine Offline",
23
- message: "The coffee machine is currently unreachable.",
24
- sound: "upbeat_bells",
25
- openUrl: "https://status.example.com/coffee-machine",
20
+ const response = await sendNotification({
21
+ webhook: process.env.BRRR_WEBHOOK!,
22
+ title: "Coffee Machine Offline",
23
+ message: "The coffee machine is currently unreachable.",
24
+ sound: "upbeat_bells",
25
+ openUrl: "https://status.example.com/coffee-machine",
26
26
  });
27
+
28
+ console.log(await response.json()); // { success: true }
27
29
  ```
28
30
 
29
31
  `webhook` can be either:
@@ -35,14 +37,15 @@ await sendNotification({
35
37
 
36
38
  ```typescript
37
39
  import type {
38
- NotificationInterruptionLevel,
39
- NotificationSound,
40
- SendNotificationParams,
40
+ NotificationInterruptionLevel,
41
+ NotificationSound,
42
+ SendNotificationParams,
41
43
  } from "brrr.now";
42
44
  import { isBrrrNowError, sendNotification } from "brrr.now";
43
45
  ```
44
46
 
45
47
  `sendNotification(params)` sends a `POST` request with a JSON payload and returns the native `Response`.
48
+ On success, the API body is `{"success":true}`.
46
49
 
47
50
  ### `SendNotificationParams`
48
51
 
@@ -58,12 +61,13 @@ import { isBrrrNowError, sendNotification } from "brrr.now";
58
61
 
59
62
  ### Error handling
60
63
 
61
- On non-`2xx` responses, `sendNotification` throws an `Error` object with extra fields:
64
+ On non-`2xx` responses, or when the API returns `{"success":false,...}`, `sendNotification` throws an `Error` object with extra fields:
62
65
 
63
66
  - `name: "BrrrNowError"`
64
67
  - `status`
65
68
  - `statusText`
66
69
  - `body`
70
+ - `apiError?`
67
71
 
68
72
  Use `isBrrrNowError` to narrow the error type:
69
73
 
@@ -71,14 +75,14 @@ Use `isBrrrNowError` to narrow the error type:
71
75
  import { isBrrrNowError, sendNotification } from "brrr.now";
72
76
 
73
77
  try {
74
- await sendNotification({
75
- webhook: process.env.BRRR_WEBHOOK!,
76
- message: "Hello world!",
77
- });
78
+ await sendNotification({
79
+ webhook: process.env.BRRR_WEBHOOK!,
80
+ message: "Hello world!",
81
+ });
78
82
  } catch (error) {
79
- if (isBrrrNowError(error)) {
80
- console.error(error.status, error.body);
81
- }
83
+ if (isBrrrNowError(error)) {
84
+ console.error(error.status, error.apiError ?? error.body);
85
+ }
82
86
  }
83
87
  ```
84
88
 
package/package.json CHANGED
@@ -1,71 +1,71 @@
1
1
  {
2
- "name": "brrr.now",
3
- "version": "1.0.0",
4
- "description": "Tiny TypeScript client for sending push notifications with brrr.now webhooks",
5
- "homepage": "https://github.com/uqe/brrr.now#readme",
6
- "bugs": {
7
- "url": "https://github.com/uqe/brrr.now/issues"
8
- },
9
- "license": "MIT",
10
- "keywords": [
11
- "brrr.now",
12
- "brrr",
13
- "notification",
14
- "push-notification",
15
- "push-notifications",
16
- "webhook",
17
- "typescript"
18
- ],
19
- "repository": {
20
- "type": "git",
21
- "url": "git+https://github.com/uqe/brrr.now.git"
22
- },
23
- "files": [
24
- "dist"
25
- ],
26
- "sideEffects": false,
27
- "type": "module",
28
- "module": "./dist/index.js",
29
- "types": "./dist/index.d.ts",
30
- "exports": {
31
- ".": {
32
- "import": {
33
- "types": "./dist/index.d.ts",
34
- "default": "./dist/index.js"
35
- }
36
- },
37
- "./package.json": "./package.json"
38
- },
39
- "scripts": {
40
- "build": "bunup",
41
- "dev": "bunup --watch",
42
- "format": "oxfmt",
43
- "lint": "oxlint",
44
- "prepare": "bun simple-git-hooks",
45
- "release": "bumpp --commit --push --tag",
46
- "test": "bun test",
47
- "test:coverage": "bun test --coverage",
48
- "test:watch": "bun test --watch",
49
- "type-check": "tsc --noEmit"
50
- },
51
- "devDependencies": {
52
- "@types/bun": "^1.3.11",
53
- "bumpp": "^11.0.1",
54
- "bunup": "^0.16.31",
55
- "oxfmt": "^0.42.0",
56
- "oxlint": "^1.57.0",
57
- "simple-git-hooks": "^2.13.1",
58
- "typescript": "^6.0.2"
59
- },
60
- "peerDependencies": {
61
- "typescript": ">=4.5.0"
62
- },
63
- "peerDependenciesMeta": {
64
- "typescript": {
65
- "optional": true
66
- }
67
- },
68
- "simple-git-hooks": {
69
- "pre-commit": "bun run lint && bun run type-check"
70
- }
2
+ "name": "brrr.now",
3
+ "version": "1.1.0",
4
+ "description": "Tiny TypeScript client for sending push notifications with brrr.now webhooks",
5
+ "keywords": [
6
+ "brrr",
7
+ "brrr.now",
8
+ "notification",
9
+ "push-notification",
10
+ "push-notifications",
11
+ "typescript",
12
+ "webhook"
13
+ ],
14
+ "homepage": "https://github.com/uqe/brrr.now#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/uqe/brrr.now/issues"
17
+ },
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/uqe/brrr.now.git"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "type": "module",
27
+ "sideEffects": false,
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "import": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.js"
35
+ }
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
39
+ "scripts": {
40
+ "build": "bunup",
41
+ "dev": "bunup --watch",
42
+ "format": "oxfmt",
43
+ "lint": "oxlint",
44
+ "prepare": "bun simple-git-hooks",
45
+ "release": "bumpp --commit --push --tag",
46
+ "test": "bun test",
47
+ "test:coverage": "bun test --coverage",
48
+ "test:watch": "bun test --watch",
49
+ "type-check": "tsc --noEmit"
50
+ },
51
+ "devDependencies": {
52
+ "@types/bun": "^1.3.11",
53
+ "bumpp": "^11.0.1",
54
+ "bunup": "^0.16.31",
55
+ "oxfmt": "^0.42.0",
56
+ "oxlint": "^1.57.0",
57
+ "simple-git-hooks": "^2.13.1",
58
+ "typescript": "^6.0.2"
59
+ },
60
+ "peerDependencies": {
61
+ "typescript": ">=4.5.0"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "typescript": {
65
+ "optional": true
66
+ }
67
+ },
68
+ "simple-git-hooks": {
69
+ "pre-commit": "bun run lint && bun run type-check"
70
+ }
71
71
  }