Lagon support
QuiiBz opened this issue · comments
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.
It'll work as soon as I figure out how to run the examples in the repo :)
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!
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).
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!
Actually I built from the source and tried to link to it with pnpm link
but I can wait of course :D
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!
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 :)
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 runningdev
- 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 forResponse
, but notRequest
, will fix
Update:
- Streaming was already fixed (but not released, see lagonapp/lagon#211)
- Added
arrayBuffer()
method toRequest
(lagonapp/lagon#210) - Added
--env
option to dev command in the CLI (lagonapp/lagon#219) - Added
X-Forwarded-For
header to get client IP (lagonapp/lagon#220) - Working on crypto APIs (lagonapp/lagon#113)
Hey! I'm wondering if there are any blockers or bugs left? I would like to work on an official HatTip adapter for Lagon.
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 :) ).
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.
Awesome! I'll also take a look at the failing tests to fix them. Thanks again!