Created
May 19, 2020 05:49
-
-
Save typebird/c94e0d5ddc60f3a0492b47dc7f5bec4a to your computer and use it in GitHub Desktop.
fastify mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fp from "fastify-plugin" | |
import SocketIOServer from "socket.io" | |
import type { FastifyInstance, FastifyError } from "fastify" | |
export default fp(( | |
fastify: FastifyInstance, | |
options: any, | |
next: (err?: FastifyError | undefined) => void) => { | |
try { | |
const io = SocketIOServer(fastify.server, options) | |
fastify.decorate("io", io) | |
next() | |
} catch (error) { | |
next(error) | |
} | |
}, { | |
name: "fastify-socket.io", | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment