{"id":28351210,"url":"https://github.com/ronitrajfr/http-server","last_synced_at":"2026-04-25T23:35:01.922Z","repository":{"id":293949308,"uuid":"985587597","full_name":"ronitrajfr/http-server","owner":"ronitrajfr","description":" HTTP server implementation built with Node.js and TypeScript that handles basic HTTP requests.","archived":false,"fork":false,"pushed_at":"2025-05-18T05:19:27.000Z","size":7,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T04:41:20.939Z","etag":null,"topics":["http","http-server","nodejs","tcp","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ronitrajfr.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}},"created_at":"2025-05-18T04:58:03.000Z","updated_at":"2025-05-18T16:55:57.000Z","dependencies_parsed_at":"2025-05-18T05:53:59.043Z","dependency_job_id":null,"html_url":"https://github.com/ronitrajfr/http-server","commit_stats":null,"previous_names":["ronitrajfr/http-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ronitrajfr/http-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronitrajfr%2Fhttp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronitrajfr%2Fhttp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronitrajfr%2Fhttp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronitrajfr%2Fhttp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ronitrajfr","download_url":"https://codeload.github.com/ronitrajfr/http-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronitrajfr%2Fhttp-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261099559,"owners_count":23109570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["http","http-server","nodejs","tcp","typescript"],"created_at":"2025-05-27T22:09:33.153Z","updated_at":"2026-04-25T23:35:01.909Z","avatar_url":"https://github.com/ronitrajfr.png","language":"TypeScript","readme":"# Simple HTTP Server\n\nA lightweight HTTP server implementation built with Node.js and TypeScript that handles basic HTTP requests.\n\n## Overview\n\nThis server is a minimalistic implementation of HTTP protocol handling, capable of:\n\n- Serving static responses\n- Echoing content from URL paths\n- Responding with the client's User-Agent\n- Basic file operations (reading and writing)\n\n## Features\n\n- Basic HTTP Response: Returns a 200 OK status code for requests to the root path (/)\n- Echo Service: Echoes content from URL path with proper content types (/echo/{content})\n- User-Agent Information: Returns the client's User-Agent header (/user-agent)\n- File Operations: Supports reading and writing files (/files/{filename})\n  - GET: Retrieve file contents\n  - POST: Create or update files\n\n## Requirements\n\n- Node.js (v14.x or later recommended)\n- TypeScript\n\n## Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/ronitrajfr/http-server.git\n   cd http-server\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   bun install\n   ```\n\n## Usage\n\nStart the server with an optional directory for file operations:\n\n```bash\nbun run dev --directory \u003cpath-to-directory\u003e\n```\n\nThe server will listen on localhost port 4221.\n\n## API Endpoints\n\n### Root (/)\n\n- Method: GET\n- Description: Returns a 200 OK response\n- Response: Empty body with 200 OK status\n\n### Echo (/echo/{content})\n\n- Method: GET\n- Description: Echoes the content from the URL path\n- Response: Content from URL with appropriate Content-Type\n- Example: /echo/hello returns \"hello\"\n- Content Types:\n  - Default: text/plain\n  - .html extension: text/html\n  - .json extension: application/json\n  - .png extension: image/png\n\n### User-Agent (/user-agent)\n\n- Method: GET\n- Description: Returns the User-Agent header from the request\n- Response: User-Agent string with text/plain Content-Type\n\n### Files (/files/{filename})\n\n- Methods: GET, POST\n- Description: Read or write files in the specified directory\n- GET Response: File contents with application/octet-stream Content-Type\n- POST Request: File content in request body\n- POST Response: 201 Created on success\n- Notes: Requires the --directory parameter when starting the server\n\n## Error Handling\n\n- 404 Not Found: Returned for non-existent routes or files\n- 405 Method Not Allowed: Returned for unsupported HTTP methods\n- 500 Internal Server Error: Returned for file operation failures\n\n## Implementation Details\n\nThe server implements HTTP request parsing from scratch:\n\n- Parses request line and headers from raw TCP socket data\n- Handles request routing based on path and method\n- Manages appropriate content types and response formats\n- Processes file operations asynchronously\n\n## Examples\n\n### Echo Example\n\n```bash\ncurl -v http://localhost:4221/echo/hello\n```\n\nResponse:\n\n```http\nHTTP/1.1 200 OK\nContent-Type: text/plain\nContent-Length: 5\n\nhello\n```\n\n### File Upload Example\n\n```bash\ncurl -v -X POST -d 'Hello, File!' http://localhost:4221/files/test.txt\n```\n\nResponse:\n\n```http\nHTTP/1.1 201 Created\n```\n\n### File Retrieval Example\n\n```bash\ncurl -v http://localhost:4221/files/test.txt\n```\n\nResponse:\n\n```http\nHTTP/1.1 200 OK\nContent-Type: application/octet-stream\nContent-Length: 12\n\nHello, File!\n```\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronitrajfr%2Fhttp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fronitrajfr%2Fhttp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronitrajfr%2Fhttp-server/lists"}