sachinraja / trpc-playground

playground for running tRPC queries in the browser
MIT License
281 stars 19 forks source link

Add a Lambda Handler #16

Open perfectbase opened 2 years ago

perfectbase commented 2 years ago

I would love to see a handler for deploying the playground on an AWS Lambda + ApiGateway structure.

Here I have an example project: https://github.com/perfectbase/serverless-trpc

It's a Next.js app with an API build with Serverless Framework.

While we don't have a Lambda Handler, I've been trying a workaround by trying to put only the playground in the Next.js's API Routes. But I wasn't successful with it.

Could you try to guide me in how I can make it work with my setup?

Thanks in advance.

sachinraja commented 2 years ago

It's easy enough for me to add a lambda handler now via https://github.com/sachinraja/uttp. The only problem is that I have no idea how to test if it actually works.

perfectbase commented 2 years ago

@sachinraja Thanks for the reply! And for the guidance! I'll try to take a look at it today.

perfectbase commented 2 years ago

@sachinraja I tried to follow the CONTRIBUTING.md instructions, but wasn't successful to make it work on the example apps.

Here is my system:

What I did:

This throws an error:

✘ [ERROR] Could not resolve "@trpc-playground/html"

    <stdin>:1:7:
      1 │ import "@trpc-playground/html"
        ╵        ~~~~~~~~~~~~~~~~~~~~~~~

Tried with the 'next' and 'express' examples as well, but wasn't successful.

image

Am I doing something wrong?

Could you tell me your system and versions so I can try to match them as close as possible?

sachinraja commented 2 years ago

You need to run pnpm build in the root I think. Sorry for any issues, the CONTRIBUTING document there is incomplete since it was just me working on this project.

If you need more help on this we could maybe do a call on the trpc discord.

perfectbase commented 2 years ago

Thanks! I could make it work for the vite example. And I think I got really close to making it work for my Serverless Framework setup.

I would like to talk on the discord some time! My name there is Ravi Souza#8573 I live in Japan, so I'll be going to sleep soon. Tell me when we can do the call. I'll be mostly free tomorrow.

sachinraja commented 2 years ago

Glad you were able to get it working. I might be free tomorrow (today?). I'm in PST. Just @ me on the discord (cloudfox) and we can talk if I'm available.