Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
fastify-sse-v2
Advanced tools
Fastify plugin for sending Server-sent events.
For fastify@2.x
use fastify-sse-v2@1.x!
yarn add fastify-sse-v2
Register fastify-sse-v2 plugin into your fastify instance:
import { FastifySSEPlugin } from "fastify-sse-v2";
const server = fastify();
server.register(FastifySSEPlugin);
import { FastifySSEPlugin } from "fastify-sse-v2";
const server = fastify();
server.register(FastifySSEPlugin);
server.get("/", function (req, res) {
res.sse(
(async function* source() {
for (let i = 0; i < 10; i++) {
sleep(2000);
yield { id: String(i), data: "Some message" };
}
})()
);
});
import { FastifySSEPlugin } from "fastify-sse-v2";
const server = fastify();
server.register(FastifySSEPlugin);
server.get("/", async function (req, res) {
for (let i = 0; i < 10; i++) {
await sleep(2000);
res.sse({ id: String(i), data: "Some message" });
}
});
fastify.get("/listenForChanges", {}, (request, reply) => {
const listenStream = fastify.db
.watch("doc-uuid")
.on("data", (data) => reply.sse({ data: JSON.stringify(data) }))
.on("delete", () => reply.sse({ event: "close" }));
request.socket.on("close", () => listenStream.end());
});
reply.sseContext.source.end()
to terminate the stream.import { FastifySSEPlugin } from "fastify-sse-v2";
import { on } from "events";
const server = fastify();
server.register(FastifySSEPlugin);
server.get("/", function (req, res) {
res.sse(
(async function* () {
for await (const [event] of on(eventEmmitter, "update")) {
yield {
event: event.name,
data: JSON.stringify(event),
};
}
})()
);
});
request.socket.on('close', () => abortController.abort());
import { FastifySSEPlugin } from "fastify-sse-v2";
const server = fastify();
server.register(FastifySSEPlugin) // retryDelay default 3000
server.register(FastifySSEPlugin, {
retryDelay: false // disable retryDelay
retryDelay: 5000 // override 5000
})
retryDelay
to false
to disable the default behavior of sending retry, or set parameter retryDelay
to milliseconds
override the default 3000 retry interval .FAQs
Fastify plugin for sending server side events.
The npm package fastify-sse-v2 receives a total of 10,283 weekly downloads. As such, fastify-sse-v2 popularity was classified as popular.
We found that fastify-sse-v2 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.