Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
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"};
}
})());
});
Using EventIterator dependency:
import {FastifySSEPlugin} from "fastify-sse-v2";
import EventIterator from "event-iterator";
const server = fastify();
server.register(FastifySSEPlugin);
server.get("/", function (req, res) {
const eventEmitter = new EventEmitter();
res.sse(new EventIterator(
(push) => {
eventEmitter.on("some_event", push)
return () => eventEmitter.removeEventListener("some_event", push)
}
)
);
});
Without additional dependency (not supported in all nodejs versions:
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 {
type: event.name,
data: JSON.stringify(event),
};
}
})()
);
});
[2.0.6]
FAQs
Fastify plugin for sending server side events.
The npm package fastify-sse-v2 receives a total of 10,709 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.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.