fastify-plugin-socket.io

1.0.0 • Public • Published

fastify-plugin-socket.io

NPM

js-standard-style

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

Install

yarn add fastify-plugin-socket.io

Usage

Require fastify-plugin-socket.io and register it as any other plugin, it will add a io decorator.

const fastify = require('fastify')()

fastify.register(require('fastify-plugin-socket.io'), {
  // put your socket.io options here
})

fastify.get('/', (req, reply) => {
  fastify.io.emit('hello world')
})

fastify.listen(3000)

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.

Acknowledgements

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

License

Licensed under MIT.
socket.io license

/fastify-plugin-socket.io/

    Package Sidebar

    Install

    npm i fastify-plugin-socket.io

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    3.62 kB

    Total Files

    4

    Last publish

    Collaborators

    • beyazatli