Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
fastify-socket.io
Advanced tools
[![CI](https://github.com/ducktors/fastify-socket.io/actions/workflows/ci.yml/badge.svg)](https://github.com/ducktors/fastify-socket.io/actions/workflows/ci.yml) [![Test](https://github.com/ducktors/fastify-socket.io/actions/workflows/test.yaml/badge.svg)
fastify-socket.io
enables the use of Socket.io in a Fastify application.
Supports Fastify versions 4.x
Supports socket.io version 4.x
npm i fastify-socket.io socket.io
Require fastify-socket.io
and register it as any other plugin, it will add a io
decorator.
const fastify = require("fastify")();
fastify.register(require("fastify-socket.io"), {
// put your options here
});
fastify.get("/", (req, reply) => {
fastify.io.emit("hello");
});
fastify.listen({ port: 3000 });
For more details see examples
You can use it as is without passing any option, or you can configure it as explained by Socket.io doc.
By default the plugin will add a preClose
hook that disconnects all the local sockets in order to close correctly the fastify server. In order to change this behaviour you can use preClose
option:
await fastify.register(require('fastify-socket.io'), {
preClose: (done) => {
// do other things
fastify.io.local.disconnectSockets(true);
done();
}
})
The plugin also adds an onClose
hook which closes the socket server when the fastify
instance is closed.
The io
decorator is NOT typed.
This is necessary to allow, eventually, the developer to be able to define custom types and make use of the socket.io
new types system (doc).
For more info see the example
The code is a port for Fastify of socket.io
.
Licensed under MIT.
socket.io
license
FAQs
[![CI](https://github.com/ducktors/fastify-socket.io/actions/workflows/ci.yml/badge.svg)](https://github.com/ducktors/fastify-socket.io/actions/workflows/ci.yml) [![Test](https://github.com/ducktors/fastify-socket.io/actions/workflows/test.yaml/badge.svg)
The npm package fastify-socket.io receives a total of 14,062 weekly downloads. As such, fastify-socket.io popularity was classified as popular.
We found that fastify-socket.io 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.