{"id":19281239,"url":"https://github.com/zouloux/static-http","last_synced_at":"2025-02-23T22:19:09.891Z","repository":{"id":61231714,"uuid":"549529896","full_name":"zouloux/static-http","owner":"zouloux","description":"0 dependency node based static http server.","archived":false,"fork":false,"pushed_at":"2022-10-28T08:49:00.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T09:18:21.463Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/zouloux.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}},"created_at":"2022-10-11T10:23:05.000Z","updated_at":"2022-10-11T11:15:13.000Z","dependencies_parsed_at":"2023-01-20T13:56:07.036Z","dependency_job_id":null,"html_url":"https://github.com/zouloux/static-http","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zouloux%2Fstatic-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zouloux%2Fstatic-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zouloux%2Fstatic-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zouloux%2Fstatic-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zouloux","download_url":"https://codeload.github.com/zouloux/static-http/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240385724,"owners_count":19793062,"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":[],"created_at":"2024-11-09T21:22:05.882Z","updated_at":"2025-02-23T22:19:09.851Z","avatar_url":"https://github.com/zouloux.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node static http\n\n0 dependency node based static http server.\n\n### ✅ Features\n\n- Super lightweight\n- Start a local static server in 1 command\n- Correct mime-types\n- Default to `index.html`\n- Directory listing if index is missing\n- Types included for Node module usage\n\n### ❌ Not included and not planned\n\n- No config\n- No CORS\n- No HTTP credentials\n- No cookies\n- No cache\n- No HLS server for media streaming\n- No automatic browser open\n- No routing system (but you can handle routes yourself with `onRequest`)\n\n### 🙏 Wishlist\n\n- Streaming of huge files (big files will be loaded entirely into RAM) ?\n- Compatibility with byte-start for video seeking ?\n- Searching for next available port automatically\n\n\n# Start a static server from your terminal\n\n##### Start with default port on current directory \n- `npx @zouloux/static-http`\n\n##### Specify root directory\n- `npx @zouloux/static-http ./docs/`\n\n##### Specify port\n- `npx @zouloux/static-http ./docs/ -p 8080` (or `--port`)\n\n# Install it globally and use it every day\n\n##### With node\n- `npm i -g @zouloux/static-http`\n\n##### With bun 🐰\n- `bun i -g @zouloux/static-http`\n\n##### Use it with\n- `static-http`\n\n\n### Start from a node script\n\n- `npm i @zouloux/static-http`\n\n```typescript\nimport { startServer } from \"@zouloux/static-http\"\n\n// Start a server with custom options.\nstartServer({\n\t// Optionnal : specify port\n\tport: 8080,\n\t// Optionnal : specify root directory\n\troot: './docs/',\n\t// Optionnal : set custom index file. Default is index.html\n\tindexFile: 'index.html',\n\t// Optionnal : allow directory indexing if index file is missing. Default is true.\n\tallowDirectoryIndex: true,\n\t// Optional - Callback executed before any request\n\tonRequest: async (request, response) =\u003e {\n\t\t// Return false to halt and disable default static behavior\n\t\t// Return true to continue static behavior\n\t\treturn true\n\t},\n\t// When any file has been statically requested\n\tonInfo: (code:number, filePath:string) =\u003e {\n\t\tconsole.log(`${code} - ${filePath}`)\n\t}\n})\n```\n\n\n## How to test\n\n1. Clone this repository\n2. `npm i`\n3. `npm run build \u0026\u0026 node dist/cli.es2020.mjs test`\n\nOpen link in console and you should see an index file with a directory listing link.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzouloux%2Fstatic-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzouloux%2Fstatic-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzouloux%2Fstatic-http/lists"}