1.1.1 • Published 6 months ago

@discordx/socket.io v1.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
6 months ago

📖 Introduction

This module is an extension of socket.io, so the internal behavior (methods, properties, ...) is the same

This library allows you to use TypeScript decorators on socket.io, it simplifies your code and improves the readability!

💻 Installation

Version 16.6.0 or newer of Node.js is required

npm install socket.io @discordx/socket.io
yarn add socket.io @discordx/socket.io

🆕 Features

  • Support multiple server in a single nodejs instance (@AppId)
  • Support TSyringe
  • Support ECMAScript

📟 @On/@Once

do not forget to wrap each class with @Ws()

import { Guard, Next, On, Once, Server, Ws } from "@discordx/socket.io";
import { Socket } from "socket.io";

@Ws()
class Example {
  @On("connection")
  @Guard(([]: [Socket], server: Server, socket: unknown, next: Next) => {
    console.log("I am mdw");
    return next();
  })
  on(): void {
    console.log("I am @onx");
  }

  @On("disconnect")
  disconnect(): void {
    console.log("I am disconnect");
  }

  @Once("connection")
  once(): void {
    console.log("I am @Once");
  }
}

📜 Documentation

☎️ Need help?

💖 Thank you

You can support discordx by giving it a GitHub star.