RangerMauve / webrun

Run Web-first ESM modules outside of the browser
https://webrun-presentation.hashbase.io/
MIT License
76 stars 4 forks source link

implementing a server with webrun #25

Open Gozala opened 5 years ago

Gozala commented 5 years ago

While I absolutely dislike service worker API, it is somewhat similar to the https(s) server API. It might be worth considering exposeing ServiceWorkerGlobalScope compatible APIs notably self.addEventListener('fetch', ...) allowing it accept requests and respond.

Although it's less clear how to one would start a server maybe something like ?

self.postMessage({ type: "http.listen", port: 8080 })

Gozala commented 5 years ago

It's worth mentioning though that in SW context there is no self.postMessage

RangerMauve commented 5 years ago

Is there anything in browsers for starting servers? Maybe copy whatever libdweb does?

tswast commented 5 years ago

We've used https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb?hl=en in codelabs for running a webserver from Chrome, but it's not exactly a browser API.

RangerMauve commented 5 years ago

That's a good idea, I think web extension style APIs would be OK.

I haven't had time to work on Webrun lately since I'm job hunting. But I'd be interested in vetting a PR if anyone wants to contribute this. 😀