serviceworker-server

1.5.0 • Public • Published

ServiceWorker Server

This project makes it easier to serve files from within the page as a regular url request.

Let's say you have a website with a service worker. In your site you've made a file that exists in

that you would like the user to download.

You can stream the file contents through your serviceworker, giving the resource a friendly URL to your site. There is a library already that handles serving files out of a downloaded torrent through a webtorrent client on the page.

// serviceworker.js
import { swserve } from 'serviceworker-server/lib/worker.js';
import { match } from 'serviceworker-server/lib/impl/webtorrent/wt-worker.js'

swserve({ match });
// client.js with a webtorrent instance in scope as `client`
import { clientserve } from 'serviceworker-server/lib/client.js';
import { match, makeHandle } from 'serviceworker-server/lib/impl/webtorrent/wt-client.js'

clientserve({ match, handle: makeHandle(client) });

Implementing your own library

Package Sidebar

Install

npm i serviceworker-server

Weekly Downloads

0

Version

1.5.0

License

Apache-2.0

Unpacked Size

10 kB

Total Files

7

Last publish

Collaborators

  • ftreesmilo