{"id":15497238,"url":"https://github.com/jwerle/sharef","last_synced_at":"2025-04-22T21:33:50.926Z","repository":{"id":148540551,"uuid":"145903358","full_name":"jwerle/sharef","owner":"jwerle","description":"Quickly share a file over HTTP, DAT, Hypercore, etc","archived":false,"fork":false,"pushed_at":"2018-09-13T22:58:12.000Z","size":38674,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-29T19:03:42.918Z","etag":null,"topics":["files","http","quickly","share"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/jwerle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-08-23T20:24:43.000Z","updated_at":"2020-05-19T03:21:43.000Z","dependencies_parsed_at":"2023-05-20T11:15:14.728Z","dependency_job_id":null,"html_url":"https://github.com/jwerle/sharef","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":"0.038461538461538436","last_synced_commit":"4f7d100d6fd69f0b5e8b157587a459be7928a1ed"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fsharef","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fsharef/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fsharef/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fsharef/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwerle","download_url":"https://codeload.github.com/jwerle/sharef/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250329193,"owners_count":21412766,"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":["files","http","quickly","share"],"created_at":"2024-10-02T08:32:16.179Z","updated_at":"2025-04-22T21:33:50.919Z","avatar_url":"https://github.com/jwerle.png","language":"JavaScript","readme":"sharef\n======\n\nQuickly share a file over HTTP, DAT, and Hypercore.\n\n## Installation\n\n```sh\n$ npm install sharef\n```\n\n## Usage\n\n`sharef` can be used as a module or from the command line. `sharef` is a\nfunction that accepts a\n[random-access-storage](https://github.com/random-access-storage/random-access-storage)\ninterface or a string that resolves to\n[random-access-http](https://github.com/random-access-storage/random-access-http) or\n[random-access-file](https://github.com/random-access-storage/random-access-file).\n\n### Command Line\n\n`sharef` describes the following command line usage.\n\n```sh\nusage: sharef [-hDV] [options] \u003cpathspec\u003e\n\nOptions:\n  -h, --help     Show help                          [boolean]\n  -V, --version  Show version number                [boolean]\n  -D, --debug    Enable debug output                [boolean] [default: false]\n  -p, --port     Port for HTTP server to listen on  [number] [default: 8000]\n  -m, --max      Max shares before exiting          [number] [default: Infinity]\n```\n\n## Example\n\nThe following example will read a file from github using a ranged\nrequest. The request is made to the `sharef` server and accessed using a\n[random-access-http](https://github.com/random-access-storage/random-access-http).\nWhen a share has occurred, the server wil close itself.\n\n```js\nconst fetch = require('got')\nconst share = require('sharef')\n\nconst file = 'https://raw.githubusercontent.com/datproject/hyperdrive-http/master/index.js'\nconst port = 8000\n\nconst server = share(file, { port })\n\nserver.once('share', onshare)\nserver.on('error', onerror)\n\nvoid async function main() {\n  const id = server.id.toString('hex')\n  const res = await fetch(`http://localhost:${port}/${id}`, {\n    headers: { range: 'bytes=0-100' }\n  })\n\n  console.log(res.body);\n}()\n\nasync function onshare(info) {\n  server.close()\n}\n\nfunction onerror(err) {\n  console.error(err.stack || err)\n}\n```\n\nThis example can be recreated on the command line by invoking the\nfollowing command:\n\n```sh\n$ sharef https://raw.githubusercontent.com/datproject/hyperdrive-http/master/index.js\n info Sharing file: https://raw.githubusercontent.com/datproject/hyperdrive-http/master/index.js\n info Server Port: 8000\n info Server ID: /b0d4281e\n info Share IP: 192.168.128.111\n info Share URL: http://192.168.128.111:8000/b0d4281e\n```\n\nIn another terminal you can request this file with `curl`.\n\n```sh\n$ curl http://192.168.128.111:8000/b0d4281e\n```\n\n## API\n\n### `server = share(storage, opts)`\n\n`share()` returns a\n[http.Server](https://nodejs.org/api/http.html#http_class_http_server)\ninstances that responds to a single route\n\n#### `server.id`\n\nA random `4` byte buffer used to identify this route.\n\n#### `server.route`\n\nA `RegExp` instance created from [path-to-regexp](\nhttps://github.com/pillarjs/path-to-regexp) that creates a unique route\nfrom `server.id`\n\n#### `server.on('share', info)`\n\nEmitted each time a \"share\" occurs. That is a successful request and\nresponse of the shared file.\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwerle%2Fsharef","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwerle%2Fsharef","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwerle%2Fsharef/lists"}