{"id":18144824,"url":"https://github.com/waithawoo/hermesockserve","last_synced_at":"2026-02-14T07:32:43.874Z","repository":{"id":260399002,"uuid":"873965991","full_name":"waithawoo/hermesockserve","owner":"waithawoo","description":"Modular Websocket Server using socket.io","archived":false,"fork":false,"pushed_at":"2025-10-18T10:27:31.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-31T14:13:11.091Z","etag":null,"topics":["broadcast","nodejs","socket","socket-io","websocket","websocket-server"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/waithawoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-17T02:54:57.000Z","updated_at":"2025-10-18T10:27:35.000Z","dependencies_parsed_at":"2024-10-31T05:17:12.127Z","dependency_job_id":"a1c6e0ca-118f-45d0-89b5-5b93c7c997a5","html_url":"https://github.com/waithawoo/hermesockserve","commit_stats":null,"previous_names":["waithawoo/hermesockserve"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/waithawoo/hermesockserve","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waithawoo%2Fhermesockserve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waithawoo%2Fhermesockserve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waithawoo%2Fhermesockserve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waithawoo%2Fhermesockserve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/waithawoo","download_url":"https://codeload.github.com/waithawoo/hermesockserve/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waithawoo%2Fhermesockserve/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29439506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T07:24:13.446Z","status":"ssl_error","status_checked_at":"2026-02-14T07:23:58.969Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["broadcast","nodejs","socket","socket-io","websocket","websocket-server"],"created_at":"2024-11-01T20:06:22.033Z","updated_at":"2026-02-14T07:32:43.858Z","avatar_url":"https://github.com/waithawoo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hermesockserve\n\nA Modular Websocket Server and HTTP API for real-time notifications using socket.io.\n\nHermesWS is a WebSocket server with an HTTP API for sending real-time notifications. This package combines both WebSocket and HTTP servers into one and can be used in any backend or frontend setup.\n\n## Installation\n\nInstall it via npm:\n\n```bash\nnpm install hermesockserve\n```\n\n## Usage\n\n```js\n// Import the required functions\nimport { startHermesWS, setHermesConfig, generateJWTToken, generateSecretKey } from 'hermesockserve';\n\n// First, Setup the required configuration values for middlewares\n// Recommend load from .env for all config values for security concerns\nsetHermesConfig('jwtSecret', 'JWT_SECRET')\nsetHermesConfig('customHeader', 'HEADER_NAME:HEADER_VALUE') // ':' must be used for delimiter\nsetHermesConfig('validApiKeys', ['apikey1','apikey2']) // Must be array type\n\n// ---- Server Setup\n// Setup WebSocket and HTTP servers with necessary configurations\nconst { expressApp, hermesWS } = await startHermesWS({\n  httpPort: 3000, // This port will serve for Http and Websocket servers\n  httpOptions: {\n    auth_middleware_types: ['jwt', 'custom-header'] // Can use 3 types : 'api-key', 'jwt' and 'custom-header'\n  },\n  wsOptions: {\n    auth_middleware_types: ['jwt', 'custom-header'] // Can use 3 types : 'api-key', 'jwt' and 'custom-header'\n  },\n  dbConfig: { dbFile: './mydb.sqlite' } // set 'null' in case of that Database is not needed\n});\n\n// Set onConnect and onDisconnect handlers \nasync function onConnect (socket){\n    console.log('Custom handler: New client connected with ID:', socket.id)\n    this.broadcastMessage('message', 'HI I am Server1')\n};\nasync function onDisconnect(socket, reason){\n    console.log(`Custom handler: Client with ID-${socket.id} disconnected. Reason:`, reason);\n};\nhermesWS.setOnConnect(onConnect)\nhermesWS.setOnDisconnect(onDisconnect)\n\n// Start the main Hermes Server\nhermesWS.start()\n\n// ---- Databases\n// Create create tables as needed\nawait hermesWS.DB().createTable('notifications', [\n    'id INTEGER PRIMARY KEY AUTOINCREMENT',\n    'sender_id TEXT',\n    'receiver_id TEXT',\n    'data TEXT',\n]);\n\nawait hermesWS.DB().insert(tableName, data) // tableName : string, data : json\nawait hermesWS.DB().query(tableName, conditions) // tableName : string, condidtion : json\n\n// ---- Websocket - Custom Events handlers and Channels\n\n// You can also add Custom Event Handlers for custom channels as follows. \n// ---- Define event handlers\nfunction onMessageChannelHandler(socket, message){\n    console.log(`Received message in onMessageChannelHandler from ${socket.id}: ${message}`);\n};\nasync function onAnnouncementChannelHandler(socket, message) {\n    console.log(`Received message in onAnnouncementChannelHandler from ${socket.id}: ${message}`);\n};\n// ---- Register custom event handlers\nhermesWS.addEventHandler('message', onMessageChannelHandler);\nhermesWS.addEventHandler('announcement', onAnnouncementChannelHandler);\n\n// Can use the hermesWS instance as 'this' in event handler functions\nfunction onMessageChannelHandler(socket, message){\n    console.log(`Received message in onMessageChannelHandler from ${socket.id}: ${message}`);\n    this.broadcastMessage('announcement', 'I am Server')\n};\n\n// ---- Http - Custom API endpoints\n// Add custom http routes if needed\nexpressApp.get('/custom-endpoint-1', (req, res) =\u003e {\n  res.send('Hello from custom endpoint 1!');\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaithawoo%2Fhermesockserve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaithawoo%2Fhermesockserve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaithawoo%2Fhermesockserve/lists"}