{"id":16641803,"url":"https://github.com/samthor/dhost","last_synced_at":"2025-07-29T20:35:28.201Z","repository":{"id":66115171,"uuid":"174787457","full_name":"samthor/dhost","owner":"samthor","description":"Never-caching development Node webserver","archived":false,"fork":false,"pushed_at":"2025-02-10T18:47:29.000Z","size":107,"stargazers_count":8,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-24T18:25:17.950Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/samthor.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}},"created_at":"2019-03-10T06:39:26.000Z","updated_at":"2023-02-15T11:05:57.000Z","dependencies_parsed_at":"2023-02-20T19:31:00.458Z","dependency_job_id":null,"html_url":"https://github.com/samthor/dhost","commit_stats":{"total_commits":82,"total_committers":2,"mean_commits":41.0,"dds":"0.012195121951219523","last_synced_commit":"68ac8d677be18377af2bb76222aff4d07146d845"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/samthor/dhost","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Fdhost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Fdhost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Fdhost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Fdhost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samthor","download_url":"https://codeload.github.com/samthor/dhost/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Fdhost/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267116743,"owners_count":24038625,"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","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"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":[],"created_at":"2024-10-12T07:47:55.345Z","updated_at":"2025-07-29T20:35:28.151Z","avatar_url":"https://github.com/samthor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"The never-caching development Node webserver for static files and ESM dev work.\nThis instructs browsers _never_ to cache any requested resources.\n**If you've ever had to mash _Ctrl/Cmd-R_ to ensure your browser is seeing the latest version of a static site, you'll know this feeling.**\n\nInstall globally via `npm -g install dhost` or `yarn global add dhost`, then run `dhost`.\n\n⚠️ This is just for development.\nDon't use it in any sort of production.\nIt reqiures Node 14+.\n\n# Running\n\nRun `dhost -h` to list all flags flags.\nBy default, this hosts only on `localhost`, on the first available port 9000 or above, and copies the serving URL to your clipboard (works on macOS, _or_ if the optional `clipboardy` is found).\n\nIf you need to serve CORS requests, run with `-c`; if you need to rewrite ESM imports in JS files, run with `-m`.\n\n# Magic\n\nThe goal of this server is not to surprise you, and to avoid magic where possible.\nIts behavior will never intentionally match any particular hosting platform's semantics.\n\nHere are the exceptions:\n\n* We serve `index.html` if found, or generate a simple directory listing otherwise\n* Symlinks generate a 302 to their target file if it's within the root (serve contents instead via `-l`)\n* No data is served for other status codes (i.e., your browser will render its own 404 page)\n\n## Modules\n\n✨ New! ✨ Specify `-m` to rewrite your JS to include static ESM imports (e.g., \"viz-observer\" =\u003e \"/node_modules/viz-observer/index.js\").\n\nThis only works on static imports (e.g., `import 'foobar';'`), not dynamic ones (e.g., `import('foobar')`), as these can be any string (including ones generated at runtime).\nIf you need to dynamically import from node_modules, add an extra helper file which doesn't need to be rewritten:\n\n```js\n// your code\nconst foobarModule = await import('./foobar-wrapper.js');\n\n// foobar-wrapper.js\nexport * from 'foobar';\n```\n\nYour build tools will compile this out, so the extra step won't effect a production build.\n\nNote that this doesn't rewrite the modules _themselves_; you'll need to depend on packages that support ESM.\n(But you should be doing that anyway, it's 2021.)\n\n# Middleware\n\nThis can be used as middleware.\nTo serve the current directory—without caching—using [Polka](https://github.com/lukeed/polka):\n\n```js\nconst polka = require('polka');\nconst dhost = require('dhost');  // or: import dhost from 'dhost';\n\npolka()\n  .use(dhost({ /* optional options */}))\n  .listen(3000, (err) =\u003e {\n    // ...\n  });\n```\n\n# Dependencies\n\nThis package has a handful of dependencies, none of which have further dependencies.\n\nNeeded for the middleware only:\n\n* `he` escapes names in generated directory listing\n* `mime` guesses mime-types for the `Content-Type` header\n\nIncluded for module rewriting support:\n\n* `gumnut` for ESM rewriting support\n* `esm-resolve` for resolving imports\n* `async-transforms` for running rewriting in parallel on multiple threads\n\nIncluded for the CLI:\n\n* `bytes` displays nicely-formatted file sizes\n* `colorette` for color output\n* `mri` parses command-line arguments\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamthor%2Fdhost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamthor%2Fdhost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamthor%2Fdhost/lists"}