
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
core.io-pubsub-mqtt
Advanced tools
This package is part of the [core.io][https://github.com/goliatone/application-cor] set of libraries, meaning it can be used independently or inside an core.io application.
To install:
$ npm i -S core.io-pubsub-mqtt
This module provides a request/response flow that you can leverage to replicate HTTP mechanics. The following illustrates a simple example
pubsub.request('ci/registry/list').then(response => {
console.log(response.message) //This is my response
}).catch(error => {
//handle error
});
pubsub.subscribe('ci/registry/list', event => {
//...perform logic to generate a result object
let result = { message: 'This is my response' };
event.respond({ result });
});
If you are using the package as a core.io module and using the dispatch/command flow, you can configure the module to behave use core.io dispatcher handling events with a respondTo function so that your commands do not have to worry about specifically handling the respond call.
Your application setup:
./commands/api.image.get.js
class ApiImageGetCommand {
execute(event) {
return {
success: true,
message: 'This is my command response'
};
}
}
./config/pubsub.js:
module.exports = {
responseTopicKey: 'responseTopic',
responseCallerKey: 'respondTo',
handlers: {
'mqtt/api/image/get': function handler(topic message) {
const context = this;
context.emit('api.image.get', message);
}
}
};
Then from your application dispatching the request:
let res = await pubsub.request('api.image.get', {filename});
You can add response middleware to build the payload of your response object. Note that the middleware will be applied before applying any transformations done in during the payload publish.
In your configuration file:
config/pubsub.js:module.exports = {
/**
* These functions will be called in the
* order they are added
*/
responseMiddleware: [
function(response, data, error) {
if(data && !error) {
response.data = data;
response.success = true;
}
if(error && !data) {
response.error = error;
response.success = false;
}
return response;
},
]
};
You can modify the payload before being published over MQTT. By default we have two transformers, one to add a timestamp and one to add a uuid to the emitted payload.
UUID transform to ensure event payloads have a unique ID.
Default implementation will add a field named uuid.
Configuration keypath: pubsub.transforms.ensure.uuid.
You can disable this transformer by setting the value of the configuration keypath to false.
Configuration options:
fieldName: String representing the payload field name, defaults to uuid.getId: function to generate the ID. Default to uuid.v4()Timestamp transform to ensure event payloads have a timestamp.
Default implementation will add a field named timestamp.
Configuration keypath: transforms.ensure.timestamp.
You can disable this transformer by setting the value of the configuration keypath to false.
Configuration options:
fieldName: String representing the payload field name, defaults to timestamp.getTimestamp: Function to generate the timestamp. Default to Date.now()® License MIT 2017 by goliatone
TODO:
FAQs
core.io PubSub transport layer providing MQTT suppor
The npm package core.io-pubsub-mqtt receives a total of 0 weekly downloads. As such, core.io-pubsub-mqtt popularity was classified as not popular.
We found that core.io-pubsub-mqtt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.