trpc-playground icon indicating copy to clipboard operation
trpc-playground copied to clipboard

Add a Lambda Handler

Open perfectbase opened this issue 3 years ago • 6 comments
trafficstars

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.

perfectbase avatar Jul 15 '22 05:07 perfectbase

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.

sachinraja avatar Jul 15 '22 13:07 sachinraja

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

perfectbase avatar Jul 16 '22 09:07 perfectbase

@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:

  • macOS Monterey (12.3) M1
  • node: v16.16.0
  • pnpm: 6.33.1 and 7.5.1 (tried with both)

What I did:

  • forked and cloned the repo
  • installed pnpm with npm i -g pnpm
  • pnpm i
  • cd apps/vite
  • pnpm dev

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?

perfectbase avatar Jul 16 '22 10:07 perfectbase

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.

sachinraja avatar Jul 16 '22 12:07 sachinraja

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.

perfectbase avatar Jul 16 '22 16:07 perfectbase

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.

sachinraja avatar Jul 16 '22 16:07 sachinraja