{"_id":"@dyniqo/ts-websocket","_rev":"5-ef558752eb9ffa852c088f4cd0139956","name":"@dyniqo/ts-websocket","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@dyniqo/ts-websocket","version":"1.0.0","keywords":["websocket","ws","typescript","ts","reconnecting","nodejs","library","ts-websocket","real-time","websocket-manager","real-time-communication","dependency-injection","modular-library","websocket-library","websocket-server","real-time-apps"],"author":{"url":"https://github.com/Dyniqo","name":"Dyniqo"},"license":"MIT","_id":"@dyniqo/ts-websocket@1.0.0","maintainers":[{"name":"dyniqo","email":"dyniqo@gmail.com"}],"homepage":"https://github.com/Dyniqo/ts-websocket","bugs":{"url":"https://github.com/Dyniqo/ts-websocket/issues"},"dist":{"shasum":"be9a57b822fd83079dab3e68d45c72d82ca040af","tarball":"https://registry.npmjs.org/@dyniqo/ts-websocket/-/ts-websocket-1.0.0.tgz","fileCount":30,"integrity":"sha512-9xtdxHmI1IlnByBgtdV+TtCdJZtArIB3SCF7+EdqRwPR1vgQniPTX9q5RTjeVqLvCy5ElSXIFdpwBUUprBt1OA==","signatures":[{"sig":"MEQCIGWOVLjTKZFG4Dc4dMt8NLDcfeCQI05RdwvouyvfMe5dAiBMuBl4ABQnRACYaMGnnH/CYJlkOAlMqEk1KGEvxXJ7CQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":57295},"main":"build/index.cjs.js","types":"./types/index.d.ts","module":"build/index.esm.js","exports":{".":{"types":"./types/index.d.ts","import":"./index.mjs","require":"./index.js"}},"gitHead":"9c13c6523562015ce74f13aebd104649ce764f17","scripts":{"test":"jest","build":"tsc -b","build:all":"npm run build && npm run build:types","typecheck":"tsc --noEmit -p tsconfig.lib.json","prepublish":"npm run build:all","test:watch":"jest --watch","build:types":"tsc -p tsconfig.types.json","build:watch":"tsc -b -w","test:coverage":"jest --coverage","build:types:watch":"tsc -p tsconfig.types.watch.json -w"},"_npmUser":{"name":"dyniqo","email":"dyniqo@gmail.com"},"repository":{"url":"git+https://github.com/Dyniqo/ts-websocket.git","type":"git"},"_npmVersion":"10.8.2","description":"A robust and flexible TypeScript library for managing WebSocket connections alongside an HTTP server. This library provides seamless integration into Node.js applications with built-in support for dependency injection, modular design, and extensibility.","directories":{},"_nodeVersion":"20.17.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ws":"^8.18.0","net":"^1.0.2","http":"^0.0.1-security","jest":"^29.7.0","tslib":"^2.3.0","express":"^4.17.1","globals":"^15.12.0","ts-jest":"^29.2.5","@types/ws":"^8.5.13","inversify":"^6.0.3","typescript":"^5.6.3","@types/jest":"^29.5.14","@types/node":"^22.9.0","jsonwebtoken":"^8.5.1","@types/express":"^5.0.0","@types/inversify":"^2.0.33","reflect-metadata":"^0.2.2","typescript-eslint":"^8.14.0","@types/jsonwebtoken":"^9.0.7"},"_npmOperationalInternal":{"tmp":"tmp/ts-websocket_1.0.0_1732260955893_0.28796290123522317","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@dyniqo/ts-websocket","version":"1.0.1","keywords":["websocket","ws","typescript","ts","reconnecting","nodejs","library","ts-websocket","real-time","websocket-manager","real-time-communication","dependency-injection","modular-library","websocket-library","websocket-server","real-time-apps"],"author":{"url":"https://github.com/Dyniqo","name":"Dyniqo"},"license":"MIT","_id":"@dyniqo/ts-websocket@1.0.1","maintainers":[{"name":"dyniqo","email":"dyniqo@gmail.com"}],"homepage":"https://github.com/Dyniqo/ts-websocket","dist":{"shasum":"43fe2453213359a980d72bf2b088ec982d5686ed","tarball":"https://registry.npmjs.org/@dyniqo/ts-websocket/-/ts-websocket-1.0.1.tgz","fileCount":8,"integrity":"sha512-4u9i+T/NiDkcZzcRxHrTeR0h467oEKwvTkuz++2EG+wwGhFnCd+A6rVKp1E1TkbqGSEXw3CEYyGV3A5LOBov6Q==","signatures":[{"sig":"MEUCIQCky/S3SYMZf8giAn1KvLCuRnPOzLRiQeFsLMlkhRlPWAIgbA9iqgS2URH4u54sq6sPl58hQx+IBzbO9DFanRcTeOQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":177245},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","scripts":{"test":"jest","build":"npm run clean && tsc && rollup -c","clean":"rimraf ./dist","typecheck":"tsc --noEmit -p tsconfig.lib.json","prepublish":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage"},"_npmUser":{"name":"dyniqo","email":"dyniqo@gmail.com"},"repository":{"url":"https://github.com/Dyniqo/ts-websocket.git","type":"git"},"description":"A robust and flexible TypeScript library for managing WebSocket connections alongside an HTTP server. This library provides seamless integration into Node.js applications with built-in support for dependency injection, modular design, and extensibility.","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2024 LorestaniMe\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"url":"^0.11.4","jest":"^29.7.0","globals":"^15.12.0","ts-jest":"^29.2.5","@types/ws":"^8.5.13","bufferutil":"^4.0.8","@types/jest":"^29.5.14","@types/node":"^22.9.0","stream-http":"^3.2.0","jsonwebtoken":"^8.5.1","@types/express":"^5.0.0","utf-8-validate":"^6.0.5","@types/inversify":"^2.0.33","reflect-metadata":"^0.2.2","typescript-eslint":"^8.14.0","@types/jsonwebtoken":"^9.0.7"},"peerDependencies":{"ws":"^8.18.0"},"_npmOperationalInternal":{"tmp":"tmp/ts-websocket_1.0.1_1732269931058_0.7603958908215049","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@dyniqo/ts-websocket","version":"1.0.2","keywords":["websocket","ws","typescript","ts","reconnecting","nodejs","library","ts-websocket","real-time","websocket-manager","real-time-communication","dependency-injection","modular-library","websocket-library","websocket-server","real-time-apps"],"author":{"url":"https://github.com/Dyniqo","name":"Dyniqo"},"license":"MIT","_id":"@dyniqo/ts-websocket@1.0.2","maintainers":[{"name":"dyniqo","email":"dyniqo@gmail.com"}],"homepage":"https://github.com/Dyniqo/ts-websocket","bugs":{"url":"https://github.com/Dyniqo/ts-websocket/issues"},"dist":{"shasum":"9744f2c6a43cf254b55242db75a52f64a2912a48","tarball":"https://registry.npmjs.org/@dyniqo/ts-websocket/-/ts-websocket-1.0.2.tgz","fileCount":6,"integrity":"sha512-QY04uaIqQfciUnkfxHAD3BGb8zkbXF3v8z9MyeOjiP0GSXrqSwOWIKoyq3+cQ+3b/sjJJhgWnXc27sHL/YJzZg==","signatures":[{"sig":"MEUCIA/hK2+pkBCoogyntl/KDqf1I1yhXiDw5A8imh9GiE3vAiEAtnp31y0r4RU4p7Pkl2IBZ+EsbIRicnDNfJcFS8XgYeg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":177245},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"7ec82213b91b800b115474ea174708008213e0ab","scripts":{"test":"jest","build":"npm run clean && tsc && rollup -c","clean":"rimraf ./dist","typecheck":"tsc --noEmit -p tsconfig.lib.json","prepublish":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage"},"_npmUser":{"name":"dyniqo","email":"dyniqo@gmail.com"},"repository":{"url":"git+https://github.com/Dyniqo/ts-websocket.git","type":"git"},"_npmVersion":"10.8.2","description":"A robust and flexible TypeScript library for managing WebSocket connections alongside an HTTP server. This library provides seamless integration into Node.js applications with built-in support for dependency injection, modular design, and extensibility.","directories":{},"_nodeVersion":"20.17.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"url":"^0.11.4","jest":"^29.7.0","globals":"^15.12.0","ts-jest":"^29.2.5","@types/ws":"^8.5.13","bufferutil":"^4.0.8","@types/jest":"^29.5.14","@types/node":"^22.9.0","stream-http":"^3.2.0","jsonwebtoken":"^8.5.1","@types/express":"^5.0.0","utf-8-validate":"^6.0.5","@types/inversify":"^2.0.33","reflect-metadata":"^0.2.2","typescript-eslint":"^8.14.0","@types/jsonwebtoken":"^9.0.7"},"peerDependencies":{"ws":"^8.18.0"},"_npmOperationalInternal":{"tmp":"tmp/ts-websocket_1.0.2_1732276628946_0.771623203583317","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@dyniqo/ts-websocket","version":"1.0.3","keywords":["websocket","ws","typescript","ts","reconnecting","nodejs","library","ts-websocket","real-time","websocket-manager","real-time-communication","dependency-injection","modular-library","websocket-library","websocket-server","real-time-apps"],"author":{"url":"https://github.com/Dyniqo","name":"Dyniqo"},"license":"MIT","_id":"@dyniqo/ts-websocket@1.0.3","maintainers":[{"name":"dyniqo","email":"dyniqo@gmail.com"}],"homepage":"https://github.com/Dyniqo/ts-websocket","bugs":{"url":"https://github.com/Dyniqo/ts-websocket/issues"},"dist":{"shasum":"e8c12ba48af984f324643887edcc740354e9dcc8","tarball":"https://registry.npmjs.org/@dyniqo/ts-websocket/-/ts-websocket-1.0.3.tgz","fileCount":8,"integrity":"sha512-Eibz/pt+mMwNlKyVru5wjhny/gYA2D/vPbMytMlBecFQ3w5qCeXPEUiqoKnYetAtyOCe4J2rVl/kOrR43QxYlQ==","signatures":[{"sig":"MEYCIQDlVFkXAqd0YpJb5oF1EQIjZw7LyN5gWWOxKHfRqBF16AIhAKfQT5k8Y14YYIBt+Fxi6BG0MAMSbc8YMFzKDJ9Avrk3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":82829},"main":"dist/ts-websocket.cjs.js","type":"module","types":"dist/ts-websocket.d.ts","module":"dist/ts-websocket.esm.js","scripts":{"test":"jest","build":"npm run clean && rollup -c","clean":"rimraf ./dist","prepublish":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage"},"_npmUser":{"name":"dyniqo","email":"dyniqo@gmail.com"},"repository":{"url":"https://github.com/Dyniqo/ts-websocket.git","type":"git"},"description":"A robust and flexible TypeScript library for managing WebSocket connections alongside an HTTP server. This library provides seamless integration into Node.js applications with built-in support for dependency injection, modular design, and extensibility.","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2024 LorestaniMe\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","dependencies":{"ws":"^8.18.0","bufferutil":"^4.0.8","jsonwebtoken":"^8.5.1","utf-8-validate":"^6.0.5","reflect-metadata":"^0.2.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jwt":"^3.2.0","net":"^3.2.0","url":"^0.11.4","http":"^3.2.0","jest":"^29.7.0","rimraf":"^5.0.0","rollup":"^3.29.1","express":"^3.2.0","globals":"^15.12.0","ts-jest":"^29.2.5","@types/ws":"^8.5.13","typescript":"^5.2.2","@types/jest":"^29.5.14","@types/node":"^22.9.0","stream-http":"^3.2.0","@types/express":"^5.0.0","@types/inversify":"^2.0.33","typescript-eslint":"^8.14.0","@types/jsonwebtoken":"^9.0.7","rollup-plugin-typescript":"^0.36.0"},"_npmOperationalInternal":{"tmp":"tmp/ts-websocket_1.0.3_1732293552490_0.1989871282725595","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"@dyniqo/ts-websocket","version":"1.0.4","author":{"name":"Dyniqo","url":"https://dyniqo.dev"},"description":"A robust and flexible TypeScript library for managing WebSocket connections alongside an HTTP server. This library provides seamless integration into Node.js applications with built-in support for dependency injection, modular design, and extensibility.","main":"dist/ts-websocket.cjs.js","module":"dist/ts-websocket.esm.js","types":"dist/ts-websocket.d.ts","type":"module","scripts":{"build":"npm run clean && rollup -c","clean":"rimraf ./dist","prepublish":"npm run build","test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage"},"keywords":["websocket","ws","typescript","ts","reconnecting","nodejs","library","ts-websocket","real-time","websocket-manager","real-time-communication","dependency-injection","modular-library","websocket-library","websocket-server","real-time-apps"],"homepage":"https://github.com/Dyniqo/ts-websocket","license":"MIT","repository":{"type":"git","url":"git+https://github.com/Dyniqo/ts-websocket.git"},"bugs":{"url":"https://github.com/Dyniqo/ts-websocket/issues"},"dependencies":{"bufferutil":"^4.0.8","reflect-metadata":"^0.2.2","utf-8-validate":"^6.0.5","ws":"^8.18.0"},"devDependencies":{"@rollup/plugin-commonjs":"^28.0.1","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.3.0","@rollup/plugin-typescript":"^12.1.1","@types/express":"^5.0.0","@types/inversify":"^2.0.33","@types/jest":"^29.5.14","@types/jsonwebtoken":"^9.0.7","@types/node":"^22.9.0","@types/ws":"^8.5.13","bufferutil":"^4.0.8","express":"^4.21.1","globals":"^15.12.0","http":"^0.0.1-security","jest":"^29.7.0","jsonwebtoken":"^9.0.2","net":"^1.0.2","rimraf":"^5.0.0","rollup":"^3.29.1","rollup-plugin-delete":"^2.1.0","rollup-plugin-dts":"^6.1.1","stream-http":"^3.2.0","ts-jest":"^29.2.5","tslib":"^2.8.1","typescript":"^5.2.2","typescript-eslint":"^8.14.0","url":"^0.11.4"},"publishConfig":{"access":"public"},"gitHead":"6346937d1460e83e7680a985f3b26889ab5a5371","_id":"@dyniqo/ts-websocket@1.0.4","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"integrity":"sha512-rbNLlNNe8jEEBhN+DhN6zsercdRPrPbGEZFF47aNyZ6QWPCOHadxwQ02iEq0wWs+8FQ2cZnL45sVVmVHul/TCw==","shasum":"c04b02a43cb5e9221a82791c005ff4c732279591","tarball":"https://registry.npmjs.org/@dyniqo/ts-websocket/-/ts-websocket-1.0.4.tgz","fileCount":6,"unpackedSize":83100,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDUCieT2hCthzL1y44z27oO7P4TEmsp0EvngX+XL26HgQIge9TOXGTLY8cQ2/TEXgSi6XffnAuZghQGRBkxtmsLD0g="}]},"_npmUser":{"name":"dyniqo","email":"dyniqo@gmail.com"},"directories":{},"maintainers":[{"name":"dyniqo","email":"dyniqo@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ts-websocket_1.0.4_1765815235576_0.030512686916341458"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-22T07:35:55.801Z","modified":"2025-12-15T16:13:55.922Z","1.0.0":"2024-11-22T07:35:56.085Z","1.0.1":"2024-11-22T10:05:31.243Z","1.0.2":"2024-11-22T11:57:09.140Z","1.0.3":"2024-11-22T16:39:12.690Z","1.0.4":"2025-12-15T16:13:55.729Z"},"bugs":{"url":"https://github.com/Dyniqo/ts-websocket/issues"},"author":{"name":"Dyniqo","url":"https://dyniqo.dev"},"license":"MIT","homepage":"https://github.com/Dyniqo/ts-websocket","keywords":["websocket","ws","typescript","ts","reconnecting","nodejs","library","ts-websocket","real-time","websocket-manager","real-time-communication","dependency-injection","modular-library","websocket-library","websocket-server","real-time-apps"],"repository":{"type":"git","url":"git+https://github.com/Dyniqo/ts-websocket.git"},"description":"A robust and flexible TypeScript library for managing WebSocket connections alongside an HTTP server. This library provides seamless integration into Node.js applications with built-in support for dependency injection, modular design, and extensibility.","maintainers":[{"name":"dyniqo","email":"dyniqo@gmail.com"}],"readme":"# WebSocket Management Library\r\n\r\nA robust and flexible TypeScript library for managing WebSocket connections alongside an HTTP server. This library provides seamless integration into Node.js applications with built-in support for dependency injection, modular design, and extensibility.\r\n\r\n---\r\n\r\n## 📜 Features\r\n\r\n- 🌐 **Unified HTTP and WebSocket Management**: Simplifies handling both HTTP and WebSocket protocols.\r\n- 🧩 **Dependency Injection**: Powered by `inversify` for modular and testable architecture.\r\n- 🛠️ **Highly Extensible**: Offers interfaces and hooks for custom implementations (e.g., authentication, logging).\r\n- 🔌 **Middleware Support**: Easily add HTTP and WebSocket middleware.\r\n- 📝 **TypeScript First**: Fully typed APIs for safer and more productive development.\r\n\r\n---\r\n\r\n## 📦 Installation\r\n\r\nInstall the package using npm or yarn:\r\n\r\n```bash\r\nnpm install @dyniqo/ts-websocket\r\n```\r\n```bash\r\nyarn add @dyniqo/ts-websocket\r\n```\r\n\r\n---\r\n\r\n## ⚙️ Usage\r\n\r\n### 🛠️ Basic Setup\r\n\r\nThe `WebSocketManager` class is the core component of the library. Here is an example of its usage:\r\n\r\n```typescript\r\nimport { WebSocketManager } from '@dyniqo/ts-websocket';\r\n\r\n// Configuration options\r\nconst options = {\r\n  port: 3000,\r\n  enableLogging: true,\r\n};\r\n\r\n// Initialize WebSocketManager\r\nconst wsManager = new WebSocketManager(options);\r\n\r\n// Start the server\r\nwsManager.start().then(() => {\r\n  console.log('WebSocket server is running!');\r\n});\r\n```\r\n\r\n---\r\n\r\n## 📚 API Documentation\r\n\r\n### 🖥️ WebSocketManager\r\n\r\n#### 📖 Methods:\r\n- `constructor(options: IWebSocketManagerOptions)`: Initialize the WebSocket manager with configuration.\r\n- `start(): Promise<void>`: Start the HTTP and WebSocket servers.\r\n- `stop(): Promise<void>`: Stop the servers gracefully.\r\n- `onConnection(handler: (socket: WebSocket) => void): void`: Register a handler for new WebSocket connections.\r\n\r\n### ⚙️ Configuration Options (IWebSocketManagerOptions)\r\nThe `IWebSocketManagerOptions` interface provides configuration properties to customize the WebSocketManager. Below are the available options:\r\n\r\n| Property         | Type                               | Default            | Description                                                                                      |\r\n|------------------|------------------------------------|--------------------|--------------------------------------------------------------------------------------------------|\r\n| `port`           | number                            | `8080`             | The port number for the WebSocket server.                                                       |\r\n| `secretKey`      | string                            | `'default_secret'` | Secret key used for token generation and authentication.                                        |\r\n| `tokenExpiry`    | string                            | `'1h'`             | The expiration duration for generated tokens (e.g., '1h', '2d').                                |\r\n| `enableLogging`  | boolean                           | `true`             | Flag to enable or disable logging.                                                              |\r\n| `wsOptions`      | `ServerOptions`                   | `undefined`        | Additional options for the WebSocket server.                                                    |\r\n| `setupRoutes`    | `(app: Application) => void`      | `undefined`        | Callback for setting up application routes in the Express application.                          |\r\n| `beforeSend`     | `(message: IMessage<any>) => void`| `undefined`        | Hook executed before a message is broadcasted.                                                  |\r\n| `afterSend`      | `(message: IMessage<any>) => void`| `undefined`        | Hook executed after a message is broadcasted.                                                   |\r\n| `onMessage`      | `(message: IMessage<any>) => void`| `undefined`        | Custom handler for processing incoming WebSocket messages.                                      |\r\n\r\n---\r\n\r\n## 🧑‍💻 Usage Example\r\n\r\n```typescript\r\nimport { WebSocketManager } from '@dyniqo/ts-websocket';\r\n\r\nconst wsManager = new WebSocketManager({\r\n  port: 8080,\r\n  secretKey: 'anySecretKey',\r\n  tokenExpiry: '2h',\r\n  enableLogging: true,\r\n  beforeSend: (message) => {\r\n    console.log('Before sending message:', message);\r\n  },\r\n  afterSend: (message) => {\r\n    console.log('After sending message:', message);\r\n  },\r\n  onMessage: (message) => {\r\n    console.log('Received message:', message);\r\n  },\r\n  setupRoutes: (app) => {\r\n    app.get('/status', (req, res) => {\r\n      res.send('Server is running!');\r\n    });\r\n  },\r\n});\r\n\r\nwsManager.start();\r\n```\r\n---\r\n\r\n## 🚀 Advanced Usage\r\n\r\n### 🔌 Middleware Integration\r\n\r\nAdd middleware for HTTP requests or WebSocket connections:\r\n\r\n```typescript\r\nwsManager.use((req, res, next) => {\r\n  console.log(`HTTP Request: ${req.method} ${req.url}`);\r\n  next();\r\n});\r\n```\r\n\r\n### 🌐 WebSocket Event Handlers\r\n\r\nDefine handlers for WebSocket events:\r\n\r\n```typescript\r\nwsManager.onConnection((socket) => {\r\n  console.log('New connection established.');\r\n\r\n  socket.on('message', (msg) => {\r\n    console.log(`Received message: ${msg}`);\r\n    socket.send('Hello, Client!');\r\n  });\r\n\r\n  socket.on('close', () => {\r\n    console.log('Connection closed.');\r\n  });\r\n\r\n  socket.on('error', (err) => {\r\n    console.error(`Error: ${err.message}`);\r\n  });\r\n});\r\n```\r\n\r\n---\r\n\r\n## 🔄 Lifecycle Hooks\r\n\r\nThe library provides lifecycle hooks to customize the behavior at different stages:\r\n\r\n### 🖥️ Server Lifecycle\r\n```typescript\r\nwsManager.onStart(() => {\r\n  console.log('Server is starting...');\r\n});\r\n\r\nwsManager.onStop(() => {\r\n  console.log('Server is shutting down...');\r\n});\r\n```\r\n\r\n### ✉️ Message Lifecycle\r\n- **`beforeSend`**: Modify or validate messages before they are sent.\r\n```typescript\r\nwsManager.beforeSend((message, socket) => {\r\n  console.log('Preparing to send message:', message);\r\n  // Modify the message if needed\r\n  return message;\r\n});\r\n```\r\n\r\n- **`afterSend`**: Perform actions after a message is sent.\r\n```typescript\r\nwsManager.afterSend((message, socket) => {\r\n  console.log('Message sent:', message);\r\n  // Additional post-send logic here\r\n});\r\n```\r\n\r\n---\r\n\r\n## 🧪 Testing\r\n\r\nRun tests using:\r\n\r\n```bash\r\nnpm run test\r\n```\r\n\r\n---\r\n\r\n## 📬 Contact Us\r\n\r\nWe'd love to hear from you! If you have questions, suggestions, or need support, here are the ways to reach us:\r\n\r\n🌐 **Website:** [Dyniqo.dev](https://dyniqo.dev)  \r\n📧 **Email:** [contact@dyniqo.dev](mailto:contact@dyniqo.dev)  \r\n🐛 **GitHub Issues:** [Open an Issue](https://github.com/Dyniqo/ts-websocket/issues)\r\n\r\nWe look forward to hearing from you!\r\n","readmeFilename":"README.md"}