![38% of CISOs Fear They’re Not Moving Fast Enough on AI](https://cdn.sanity.io/images/cgdhsj6q/production/faa0bc28df98f791e11263f8239b34207f84b86f-1024x1024.webp?w=400&fit=max&auto=format)
Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@backstage/plugin-signals-node
Advanced tools
Node.js library for the signals plugin
Welcome to the Node.js library package for the signals plugin!
Signals plugin allows backend plugins to publish messages to frontend plugins.
In packages/backend/index.ts
, add the signals backend:
backend.add(import('@backstage/plugin-signals-backend'));
To use signals in your plugin, add it as a dependency to my-plugin/plugin.ts
:
import {
coreServices,
createBackendPlugin,
} from '@backstage/backend-plugin-api';
import { signalsServiceRef } from '@backstage/plugin-signals-node';
export const myPlugin = createBackendPlugin({
pluginId: 'my-plugin',
register(env) {
env.registerInit({
deps: {
httpRouter: coreServices.httpRouter,
signals: signalsServiceRef,
},
async init({ httpRouter, signals }) {
httpRouter.use(
await createRouter({
signals,
}),
);
},
});
},
});
Add SignalService to your plugin environment in packages/backend/src/types.ts
:
import { SignalsService } from '@backstage/plugin-signals-node';
export type PluginEnvironment = {
// ...
signals: SignalsService;
};
Add it also to your makeCreateEnv
to allow access from the other plugins:
import {
SignalsService,
DefaultSignalsService,
} from '@backstage/plugin-signals-node';
import { DefaultEventBroker } from '@backstage/plugin-events-backend';
function makeCreateEnv(config: Config) {
// ...
const eventBroker = new DefaultEventBroker(root.child({ type: 'plugin' }));
const signalsService = DefaultSignalsService.create({
eventBroker,
});
return (plugin: string): PluginEnvironment => {
const logger = root.child({ type: 'plugin', plugin });
return {
logger,
eventBroker,
signals: signalsService,
// ...
};
};
}
To allow connections from the frontend, you should also install the @backstage/plugin-signals-backend
.
Once you have both of the backend plugins installed, you can utilize the signal service by calling the
publish
method. This will publish the message to all subscribers in the frontend. To send message to
all subscribers, you can use broadcast
type:
// Periodic sending example
setInterval(async () => {
await signals.publish({
recipients: { type: 'broadcast' },
channel: 'my_plugin',
message: {
message: 'hello world',
},
});
}, 5000);
To receive this message in the frontend, check the documentation of @backstage/plugin-signals
and
@backstage/plugin-signals-react
.
Other way to send signals is to utilize the EventBroker
directly. This requires that the payload is correct for it
to work:
eventBroker.publish({
topic: 'signals',
eventPayload: {
recipients: { type: 'user', entityRef: 'user:default/user1' },
message: {
message: 'hello world',
},
channel: 'my_plugin',
},
});
FAQs
Node.js library for the signals plugin
The npm package @backstage/plugin-signals-node receives a total of 14,962 weekly downloads. As such, @backstage/plugin-signals-node popularity was classified as popular.
We found that @backstage/plugin-signals-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.