@applogico/blipr-mcp 0.1.3 → 0.1.4
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/dist/publish.js +7 -5
- package/package.json +1 -1
package/dist/publish.js
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Publish a message to a Blipr topic. Returns the resolved topic on success.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Posts to `POST /api/notify/{topic}` (topic in the URL) with a JSON body. JSON
|
|
6
|
+
* is UTF-8, so titles/messages with emoji or accents survive — HTTP headers are
|
|
7
|
+
* Latin-1 only and would corrupt or reject them.
|
|
8
8
|
*/
|
|
9
9
|
export async function publish(opts, cfg) {
|
|
10
10
|
const topic = (opts.topic ?? cfg.defaultTopic ?? "").trim();
|
|
11
11
|
if (!topic) {
|
|
12
12
|
throw new Error("No topic given and BLIPR_TOPIC is not set. Pass `topic`, or set the BLIPR_TOPIC env var.");
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
// Topic goes in the URL path; everything else is the JSON body.
|
|
15
|
+
const payload = { message: opts.message };
|
|
15
16
|
if (opts.title)
|
|
16
17
|
payload.title = opts.title;
|
|
17
18
|
if (opts.priority)
|
|
@@ -21,9 +22,10 @@ export async function publish(opts, cfg) {
|
|
|
21
22
|
if (opts.click)
|
|
22
23
|
payload.click = opts.click;
|
|
23
24
|
const base = cfg.bliprUrl.replace(/\/+$/, "");
|
|
25
|
+
const url = `${base}/api/notify/${encodeURIComponent(topic)}`;
|
|
24
26
|
let res;
|
|
25
27
|
try {
|
|
26
|
-
res = await fetch(
|
|
28
|
+
res = await fetch(url, {
|
|
27
29
|
method: "POST",
|
|
28
30
|
headers: { "Content-Type": "application/json" },
|
|
29
31
|
body: JSON.stringify(payload),
|