Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ducktors/fastify-socket.io

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ducktors/fastify-socket.io

![CI workflow](https://github.com/ducktors/fastify-socket.io/workflows/CI%20workflow/badge.svg)

  • 0.0.2
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

@ducktors/fastify-socket.io

CI workflow

fastify-socket.io enables the use of Socket.io in a Fastify application.

Supports Fastify versions 4.x

Install

npm i fastify-socket.io socket.io

Usage

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.

Hook

The plugin also adds an onClose hook which closes the socket server when the fastify instance is closed.

Typescript

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

Acknowledgements

The code is a port for Fastify of socket.io.

License

Licensed under MIT.
socket.io license

FAQs

Package last updated on 24 Aug 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc