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

Lagon support #32

Closed
QuiiBz opened this issue Oct 17, 2022 · 12 comments
Closed

Lagon support #32

QuiiBz opened this issue Oct 17, 2022 · 12 comments

Comments

@QuiiBz
Copy link
Contributor

QuiiBz commented Oct 17, 2022

Hello! This is an issue to track the support of Lagon with HatTip. I've created an issue in Lagon's repo too:

It should already work out-of-the-box, but it's a good idea to keep a reference.

@cyco130
Copy link
Member

cyco130 commented Oct 18, 2022

It'll work as soon as I figure out how to run the examples in the repo :)

@QuiiBz
Copy link
Contributor Author

QuiiBz commented Oct 18, 2022

It'll work as soon as I figure out how to run the examples in the repo :)

I've merged the lagon dev command yesterday, which allows running a function on your computer, using the exact same runtime. Still need to add live reload and write some docs about the CLI, but it will be much easier after that!

@cyco130
Copy link
Member

cyco130 commented Oct 18, 2022

I'm able to build a function, and the output looks good to me. But lagon dev just prints dev and exists whether I give it .lagon/index.js or the actual source file (which is essentially the same as the output at the moment).

@QuiiBz
Copy link
Contributor Author

QuiiBz commented Oct 18, 2022

Yeah, haven't made a new release to include the dev command yet 😅 Should be out in a couple of days after I add live reload!

@cyco130
Copy link
Member

cyco130 commented Oct 18, 2022

Actually I built from the source and tried to link to it with pnpm link but I can wait of course :D

@hattipjs hattipjs deleted a comment from QuiiBz Oct 21, 2022
@QuiiBz
Copy link
Contributor Author

QuiiBz commented Oct 21, 2022

Update: I'm made a basic documentation for the CLI and released some fixes and improvements.

You should be able to install it with npm i -g @lagon/cli, and then run a local dev server with lagon dev <file>. Feel free to reach me on Discord if you have any issues!

@cyco130
Copy link
Member

cyco130 commented Oct 24, 2022

Progress report time!

I was able to make things work, enough to run the simple test suite, with the following entry point:

import hattipHandler from ".";

export async function handler(request) {
  return hattipHandler({
    request,
    ip: "",
    platform: {},
    passThrough() {},
    waitUntil() {},
  });
}

What worked:

  • Serving static files
  • Responding with binary data
  • Request.prototype.text()
  • Responding with text
  • Search params (URL object), single cookies, status, and headers

What didn't work:

  • No way to get the IP address (related to the environment rather than the runtime)
  • No way to get environment variables (ditto)
  • Returning a ReadableStream as response body
  • Request.prototype.arrayBuffer()
  • No way to set multiple cookies
  • No crypto global
  • Some problem with the GraphQL middleware which I couldn't really figure out (probably related to import/export conditions)

Not a bad start at all :)

@QuiiBz
Copy link
Contributor Author

QuiiBz commented Oct 24, 2022

Thanks for taking the time to test all of this!

  • I'll probably add an X-Real-Ip header to each request to include the IP
  • Env variables are injected through process.env, but this might change. But I think the CLI should load a .env file when running dev - let me log an issue for this!
  • Could you provide a reproduction for ReadableStream? I've implemented it a week ago, so it might have some bugs
  • arrayBuffer() has been implemented for Response, but not Request, will fix

Update:

@QuiiBz
Copy link
Contributor Author

QuiiBz commented Dec 18, 2022

Hey! I'm wondering if there are any blockers or bugs left? I would like to work on an official HatTip adapter for Lagon.

@cyco130
Copy link
Member

cyco130 commented Dec 20, 2022

I think we're almost there. There's a small issue in FormData with application/x-www-form-urlencoded but that should be an easy fix. I'll have a look at it in a few days. Then we can finally release @hattip/adapter-lagon (which will be like three lines of code anyway :) ).

@cyco130
Copy link
Member

cyco130 commented Dec 25, 2022

I just released @hattipjs/adapter-lagon, Lagon is now officially supported 🎉.

There are a few failing tests (most adapters have a few). I will have a closer look on each of them later and open issues/PRs on the Lagon repo.

@cyco130 cyco130 closed this as completed Dec 25, 2022
@QuiiBz
Copy link
Contributor Author

QuiiBz commented Dec 25, 2022

Awesome! I'll also take a look at the failing tests to fix them. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants