{"id":18030115,"url":"https://github.com/humphd/nohost","last_synced_at":"2025-04-09T13:08:01.633Z","repository":{"id":15593710,"uuid":"18329694","full_name":"humphd/nohost","owner":"humphd","description":"A web server in your web browser","archived":false,"fork":false,"pushed_at":"2019-04-04T18:29:47.000Z","size":6057,"stargazers_count":283,"open_issues_count":6,"forks_count":38,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-02T07:53:08.783Z","etag":null,"topics":["browser","filer","filesystem","fs","posix","service-worker","web-server"],"latest_commit_sha":null,"homepage":null,"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/humphd.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}},"created_at":"2014-04-01T13:07:34.000Z","updated_at":"2025-03-26T19:13:51.000Z","dependencies_parsed_at":"2022-07-21T06:47:14.473Z","dependency_job_id":null,"html_url":"https://github.com/humphd/nohost","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphd%2Fnohost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphd%2Fnohost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphd%2Fnohost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphd%2Fnohost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/humphd","download_url":"https://codeload.github.com/humphd/nohost/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045233,"owners_count":21038553,"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":["browser","filer","filesystem","fs","posix","service-worker","web-server"],"created_at":"2024-10-30T09:13:19.401Z","updated_at":"2025-04-09T13:08:01.611Z","avatar_url":"https://github.com/humphd.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# nohost\n\nA web server in your web browser.\n\n## Overview\n\nnohost uses [Filer](https://github.com/filerjs/filer) to run a node'js style,\nPOSIX filesystem inside a Service Worker, and handle requests for static files and\ndirectories.\n\nThe most likely use case for nohost would be an app that uses Filer to run a filesystem\nin the window, and then use nohost to provide a way to interact with that filesystem\nin the browser via URLs, like one would with Apache or another web server hosting static files.\n\n## Example\n\nNOTE: I don't currently have a full demo up (TODO), so the default filesystem is empty.  My plan\nis to rework this into a module people can include along with Filer to allow\nself-hosting of static files in the browser.\n\nUntil then, here's what nohost looks like running with a fileystem manually created:\n\n![Example running](screenshots/demo.png)\n\nClicking a link does what you'd expect, serving the file to the browser via the Service Worker.\n\n## Installation\n\nTo run it:\n\n```\nnpm install\nnpm run build\n```\n\nThe nohost Service Worker will be built in `dist/nohost-sw.js`. NOTE: you can also use `npm run dev` to also start a web server.\n\nNow register nohost's Service Worker in your app at startup:\n\n```js\nif(!('serviceWorker' in navigator)) {\n  console.warn('unable to initialize nohost service worker: not supported.');\n} else {\n  navigator.serviceWorker\n    .register('./nohost-sw.js') // see configuration options below\n    .catch(err =\u003e {\n      console.error(`unable to register nohost service worker: ${err.message}`);\n    });\n}\n```\n\n## Configure Web Server\n\nVarious features of the nohost web server can be configured by passing options on\nthe query string when registering the `nohost-sw.js` Service Worker:\n\n* `route` (`String`): with the route name to use when listening for filesystem path requests. Defaults to `fs`, such that `/fs/path/to/file` would respond with `/path/to/file`\n\n* `disableIndexes` (`Boolean`, present or absent): directory indexes (i.e., listings) will *not* be shown.  By default they *will* be shown. If defined, users will have to know the filename they wish to get back from the server.\n\n* `directoryIndex` (`String`): overrides the default directory index filename, used when a directory path is given. Defautls to `index.html`. For example, `/fs/` would return `/fs/index.html` by default (if present).  If another name is specified here, that filename will be used instead.\n\nFor example:\n\n```js\n// Use /www for the server route, and disable directory listings\nnavigator.serviceWorker\n  .register('./nohost-sw.js?route=www\u0026disableIndexes');\n```\n\n## Browse Filesystem\n\nAfter the Service Worker is installed, you can then browse into the filesystem via\nthe specified route (defaults to `/fs/*`). For example, if running the demo:\n`http://localhost:8080/fs/*`, where `/*` is a path into the filesystem.\n\nTo get metadata about files/directories vs. contents, add `?json` to the URL.\nFor example: `http://localhost:8080/fs/dir?json`\n\nTo download instead of view files in the browser, add `?download` or `?dl` to the URL.\nFor example: `http://localhost:8080/fs/path/to/file.png?dl`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumphd%2Fnohost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumphd%2Fnohost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumphd%2Fnohost/lists"}