feat: migrate from express to fastify

This commit is contained in:
Divlo
2021-10-24 04:18:18 +02:00
parent 714cc643ba
commit b77e602358
281 changed files with 19768 additions and 22895 deletions

View File

@ -0,0 +1,19 @@
import fastifyPlugin from 'fastify-plugin'
import { Server as SocketIoServer, ServerOptions } from 'socket.io'
declare module 'fastify' {
export interface FastifyInstance {
io: SocketIoServer
}
}
export default fastifyPlugin(
async (fastify, options: Partial<ServerOptions>) => {
const socket = new SocketIoServer(fastify.server, options)
fastify.decorate('io', socket)
fastify.addHook('onClose', async (fastify) => {
fastify.io.close()
})
},
{ fastify: '3.x' }
)