{"id":22423267,"url":"https://github.com/soham901/simple-streaming-nodejs","last_synced_at":"2026-07-04T04:02:20.760Z","repository":{"id":266679443,"uuid":"899017714","full_name":"soham901/simple-streaming-nodejs","owner":"soham901","description":"a simple implementation of response streaming using Node.js","archived":false,"fork":false,"pushed_at":"2024-12-05T13:39:22.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T06:41:26.571Z","etag":null,"topics":["nodejs","streaming-data"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/soham901.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-12-05T13:21:17.000Z","updated_at":"2025-01-05T12:05:06.000Z","dependencies_parsed_at":"2024-12-05T14:33:56.794Z","dependency_job_id":"be3cf75c-4979-47d6-88c9-311b2f92c409","html_url":"https://github.com/soham901/simple-streaming-nodejs","commit_stats":null,"previous_names":["soham901/simple-streaming-nodejs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/soham901/simple-streaming-nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soham901%2Fsimple-streaming-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soham901%2Fsimple-streaming-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soham901%2Fsimple-streaming-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soham901%2Fsimple-streaming-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soham901","download_url":"https://codeload.github.com/soham901/simple-streaming-nodejs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soham901%2Fsimple-streaming-nodejs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35109212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-04T02:00:05.987Z","response_time":113,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","streaming-data"],"created_at":"2024-12-05T18:09:50.914Z","updated_at":"2026-07-04T04:02:20.728Z","avatar_url":"https://github.com/soham901.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Response Streaming Demo in Node.js\n\nThis mini project demonstrates a simple implementation of response streaming using Node.js. It serves mock user data through an HTTP server, simulating a delay between each record to showcase the streaming behavior.\n\n## Features\n\n- HTTP server built with Node.js native `http` module\n- Streams mock user data from a JSON file\n- Simulates delay between records for demonstration purposes\n- Serves a static HTML file for the frontend\n- Handles both GET and POST requests\n- Zero dependencies except for the native `http` module\n\n## Technologies Used\n\n- Node.js\n- Native `http` module\n- JavaScript Fetch API\n- JSON for mock data\n- HTML/CSS for frontend\n\n## Prerequisites\n\n- Node.js (version 14 or later recommended)\n\n## Setup\n\n1. Clone this repository:\n\n   ```bash\n   git clone https://github.com/soham901/simple-streaming-nodejs.git\n   cd simple-streaming-nodejs\n   ```\n\n2. Create a `mock_users.json` file in the project root with your sample user data.\n\n3. Create an `index.html` file in the project root for the frontend.\n\n## Usage\n\n1. Start the server:\n\n   ```bash\n   node index.js\n   ```\n\n2. Open a web browser and navigate to `http://localhost:3000`\n\n3. The page will automatically start fetching and displaying the streamed data.\n\n## How it works\n\n- The server reads the `mock_users.json` file and streams each record with a simulated delay.\n- When a POST request is received, the server sets up a chunked transfer encoding and streams the data.\n- The frontend JavaScript fetches the data using the Fetch API and processes the stream as it arrives.\n\nHere's a snippet of the core streaming functionality:\n\n```javascript\nasync function* generateStream() {\n  const data = JSON.parse(readFileSync(\"mock_users.json\", \"utf8\"));\n\n  for (const record of data) {\n    await new Promise((resolve) =\u003e setTimeout(resolve, 1000)); // Simulate delay\n    yield JSON.stringify(record) + \"\\n\";\n  }\n}\n\n// In the request handler:\nfor await (const chunk of generateStream()) {\n  res.write(chunk); // Write each chunk of data\n}\n```\n\n## Customization\n\n- Adjust the `PORT` constant in `server.js` to change the server port.\n- Modify the delay in the `generateStream` function to change the streaming speed.\n- Update the `mock_users.json` file to use different sample data.\n\n## Use-Cases\n\n- Simulating real-time data streaming for real-time applications.\n- Demonstrating the concept of server-sent events (SSE).\n- Exploring the capabilities of Node.js for handling large datasets.\n\n## Why I built this\n\nI was working on a client project where I'm using an AI API that was taking ~2m to return the data. I wanted to try utilizing streaming to improve the user experience, so I built this as an experiment.\n\n## Drawbacks\n\n- The code is not optimized for production use.\n- The server doesn't handle errors gracefully.\n- The server doesn't handle client disconnections gracefully.\n- Not using TypeScript and other build tools.\n- Not using a library for handling streaming or HTTP communication.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Author\n\nSoham Sagathiya - [@soham901](https://github.com/soham901)\n\n- GitHub: https://github.com/soham901\n- LinkedIn: https://www.linkedin.com/in/soham-sagathiya/\n- X: https://x.com/soham901x\n\nLet's collaborate and build something amazing together!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoham901%2Fsimple-streaming-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoham901%2Fsimple-streaming-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoham901%2Fsimple-streaming-nodejs/lists"}