Open linonetwo opened 6 years ago
The first goal here is to allow a website to import this service-worker-gateway
package and use it for getting files from an IPFS node running in the service-worker, abstracting everything from the app.
@vasco-santos I thought that was the goal of ipfs-service-worker
?
And service-worker-gateway
is letting a website have a route that will load content from IPFS.
sw-toolbox let user write two lines of code:
// public/my-service-worker.js
importScripts('bower_components/sw-toolbox/sw-toolbox.js'); // Update path to match your own setup
and
// index.js
navigator.serviceWorker.register('my-service-worker.js');
It's difficult to import script in service worker. There is no
window
orglobal
in SW, and we can't get an object thatexports
by an npm package.I think https://cdn.jsdelivr.net/npm/ipfs/dist/index.js is a good example to follow, it injects a
Ipfs
object to the context.Then how will the API be? Are we going to export a function likes
getFile
and let user write this boilerplate code?