Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Networking Module #14

Open
Redfire75369 opened this issue Oct 7, 2021 · 5 comments
Open

HTTP Networking Module #14

Redfire75369 opened this issue Oct 7, 2021 · 5 comments
Labels
Feature: Module Additional and Improvements to Standard Modules Type: Help Wanted Extra Attention is Needed

Comments

@Redfire75369
Copy link
Owner

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.

@Redfire75369 Redfire75369 added Feature: Module Additional and Improvements to Standard Modules Type: Help Wanted Extra Attention is Needed labels Oct 7, 2021
@gimbling-away
Copy link

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

@Redfire75369
Copy link
Owner Author

Redfire75369 commented Jan 2, 2022

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.

@pi0
Copy link

pi0 commented Oct 3, 2023

Looking forward for this to early try for Nitro (nitrojs/nitro#1781) and Nuxt!

@lino-levan
Copy link
Contributor

Once web streams land in spiderfire, I'd be interested in seeing fetch implemented.

@Redfire75369
Copy link
Owner Author

Redfire75369 commented Feb 15, 2024

To be precise, there's already a basic implementation of fetch, mostly in favour of a http client module. The main caveat being it doesn't support streams.
You can see roughly what's supported here: fetch.d.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Module Additional and Improvements to Standard Modules Type: Help Wanted Extra Attention is Needed
Projects
None yet
Development

No branches or pull requests

4 participants