spiderfire
spiderfire copied to clipboard
HTTP Networking Module
Issue
Spiderfire currently lacks a networking module, making it impossible to use this as a serverside runtime, and serve webpages for example. It is also unable to fetch data from web APIs. Implementing a networking module will be essential for spiderfire's usage.
Possible Solution
hyper or reqwest can be used to provide HTTP networking APIs in a module.
How do importing other files currently work in spiderfire?
I propose a syntax like
let request = http.get("https://my.dopeapi.dev/get", {"headers": {"Authorization": "my_token"}});
console.log(request.response);
and we could also implement an HTTP handler for more efficient handling of multiple http requests
let handler = http.newHandler();
handler.get(...);
handler.delete(...);
I'd also recommend the ureq crate -- https://lib.rs/ureq
Importing is currently along the lines of
import fs from "fs";
import {get} from "./http.js";
Both of those methods (directly sending a request) and creating a request handler/agent to request without passing the options every time are planned.
I was planning to use hyper
, but I can definitely take a look at ureq
. My main issue with ureq
is probably the lack of an asynchronous API.