{"id":32613903,"url":"https://github.com/krlan2789/micro-ws-app","last_synced_at":"2026-05-02T22:37:24.990Z","repository":{"id":316289235,"uuid":"1062756203","full_name":"krlan2789/micro-ws-app","owner":"krlan2789","description":"μWebSockets.js Project - Similar to Express.js + WebSocket standard library, but faster","archived":false,"fork":false,"pushed_at":"2026-01-03T10:39:18.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-02T22:36:57.940Z","etag":null,"topics":["nodejs","postgresql","typescript","uwebsocketsjs","uws","websocket-server"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krlan2789.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T17:24:37.000Z","updated_at":"2026-01-03T10:39:22.000Z","dependencies_parsed_at":"2025-09-23T19:34:46.091Z","dependency_job_id":null,"html_url":"https://github.com/krlan2789/micro-ws-app","commit_stats":null,"previous_names":["krlan2789/micro-ws-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/krlan2789/micro-ws-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krlan2789%2Fmicro-ws-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krlan2789%2Fmicro-ws-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krlan2789%2Fmicro-ws-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krlan2789%2Fmicro-ws-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krlan2789","download_url":"https://codeload.github.com/krlan2789/micro-ws-app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krlan2789%2Fmicro-ws-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32552376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T22:28:24.418Z","status":"ssl_error","status_checked_at":"2026-05-02T22:28:14.225Z","response_time":132,"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":["nodejs","postgresql","typescript","uwebsocketsjs","uws","websocket-server"],"created_at":"2025-10-30T15:55:19.019Z","updated_at":"2026-05-02T22:37:24.983Z","avatar_url":"https://github.com/krlan2789.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Building a Fast Real-Time Application with µWebSockets.js\n\nReal-time applications are revolutionizing the way we interact with technology, enabling instantaneous communication and updates. At the core of these systems lies WebSocket technology, which facilitates seamless two-way communication between clients and servers. In this article, we will delve into the process of building a WebSocket-based application using [uWebSockets.js](https://github.com/uNetworking/uWebSockets.js), covering everything from prerequisites to deployment.\n\n## Why Choose µWebSockets.js Over Express.js + ws?\n\nWhile Express.js combined with the `ws` (WebSocket Standard) library is a popular choice for building WebSocket applications, µWebSockets.js offers several advantages that make it ideal for high-performance, real-time systems:\n\n- **Performance**: µWebSockets.js is engineered for speed and efficiency, handling significantly more concurrent connections and messages than Express.js + ws.\n- **Low Latency**: Its optimized C++ core delivers lower latency, making it suitable for applications where real-time responsiveness is critical.\n- **Resource Efficiency**: µWebSockets.js consumes less memory and CPU, allowing you to scale your application with fewer resources.\n- **Built-in Features**: It provides advanced features like native SSL support, per-message compression, and automatic ping/pong handling out of the box.\n- **Scalability**: Designed for large-scale deployments, µWebSockets.js can handle millions of simultaneous connections with minimal overhead.\n\nFor applications demanding maximum throughput and minimal delay—such as chat systems, live dashboards, or multiplayer games—µWebSockets.js is a superior choice.\n\n## Prerequisites\n\nBefore diving into the setup, ensure you have the following tools and versions installed:\n\n- **NodeJS**: `20.18.0`\n- **NPM**: `10.8.2`\n- **TypeScript**: `5.9.2`\n- **uWebSockets.js**: `20.52.0`\n- **PostgreSQL**: `12.14`\n\nThese tools form the backbone of the application, enabling efficient development and database management.\n\n## Setting Up the Project\n\n### Step 1: Cloning the Repository\n\nBegin by cloning the project repository to your local machine. This repository contains all the necessary files and configurations to get started:\n\n```shell\n$ git clone https://github.com/krlan2789/micro-ws-app.git\n```\n\n### Step 2: Navigating to the Project Directory\n\nOnce cloned, navigate to the project directory:\n\n```shell\n$ cd micro-wss-app\n```\n\n### Step 3: Installing Dependencies\n\nInstall the required dependencies using NPM. This ensures that all necessary packages are available for the application:\n\n```shell\n$ npm install\n```\n\nAlternatively, you can use the shorthand command:\n\n```shell\n$ npm i\n```\n\n## Configuring the Database\n\nTo enable database connectivity, follow these steps:\n\n### Step 1: Creating an Environment File\n\nDuplicate the `example.env` file or create a new `.env` file in the project root directory. This file will store your application and database settings.\n\n### Step 2: Updating the Configuration\n\nEdit the `.env` file with your specific database credentials and application settings:\n\n```ini\nAPP_PORT=3006\nUWS_IDLE_TIMEOUT=30\nUWS_MAX_PAYLOAD_LENGTH=1024\n\nDB_USER=postgres\nDB_HOST=localhost\nDB_NAME=db_name\nDB_PASS=password\nDB_PORT=5432\nDB_MAX_CONNECTION=16\nDB_IDLE_TIMEOUT=30000\n```\n\nThese configurations ensure seamless communication between the application and the PostgreSQL database.\n\n## Running the Application\n\nWith the setup complete, you can now run the application. Choose the appropriate mode based on your requirements:\n\n### Step 1: Navigating to the Project Directory\n\nEnsure you are in the project directory:\n\n```shell\n$ cd micro-wss-app\n```\n\n### Step 2: Starting the Application\n\n- **Development Mode**: Ideal for testing and debugging during development.\n\n\t```shell\n\t$ npm run dev\n\t```\n\n- **Production Mode**: Suitable for deploying the application in a live environment.\n\n\t```shell\n\t$ npm start\n\t```\n\n- **Production Mode with PM2**: For enhanced process management, use PM2 (requires installation).\n\n\t```shell\n\t$ npm start:pm2\n\t```\n\n### Step 3: Testing the WebSocket Connection\n\nTo verify the WebSocket functionality, use a WebSocket testing tool and connect using the following URL format:\n\n```http\n[ws/wss]://[ip/hostname]:[port]?token=user_token\n```\n\n#### Example URLs:\n\n- **HTTP**: `ws://localhost:8765?token=user1240635408404344554`\n- **HTTPS**: `wss://localhost:8765?token=user1240635408404344554`\n\nAlternatively, you can run the following command to test the WebSocket connection:\n\n```shell\n$ npm run test:ws\n```\n\n## Deploying the Application\n\nDeploying the application to a VPS or cloud hosting environment is straightforward. For detailed instructions, refer to [this (Nginx)](/secure-websocket-service-on-vps-using-nginx) or [this (Apache)](/secure-websocket-service-on-vps-using-apache) deployment notes.\n\n## Conclusion\n\nBy following this guide, you can efficiently set up and run a WebSocket-based application using µWebSockets.js. This setup is perfect for building real-time features such as chat applications, live notifications, or collaborative tools. With WebSocket technology, the possibilities for creating dynamic and interactive applications are endless.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrlan2789%2Fmicro-ws-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrlan2789%2Fmicro-ws-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrlan2789%2Fmicro-ws-app/lists"}