17 lines
539 B
JavaScript
17 lines
539 B
JavaScript
const webdisBaseURL = "https://iva.mortons.site/webdis/";
|
|
|
|
return {
|
|
async publish(channel, message) {
|
|
const str = JSON.stringify(message);
|
|
const encodedStr = buffer.Buffer.from(str).toString("base64");
|
|
let escapedStr = encodedStr.replace(/\//g, "%2f");
|
|
escapedStr = escapedStr.replace(/\+/g, "%2B");
|
|
|
|
console.log(`webdis:PUBLISH/${channel}/${escapedStr}`);
|
|
axios
|
|
.post(webdisBaseURL, `PUBLISH/${channel}/${escapedStr}`)
|
|
.then(function (response) {
|
|
console.log(response.data);
|
|
});
|
|
},
|
|
}; |