Replies: 2 comments 2 replies
-
This would be a great addition to the adapters! I was talking to a company that would want a very similar thing, I think - @thisdotrob, can you share what you ended up with? You can use If you want to add an official adapter, you can like at the next.js one for a reference implementation. Also happy to jump on a call and talk through the codebase if you're interested in contributing. |
Beta Was this translation helpful? Give feedback.
-
I found this project today and I am very excited to try this. I believe for my own use case running something like this on AWS lambda would be beneficial for me and my project. I had a look into creating a handler that would work for an AWS lambda, I spent about an hour. Perhaps this is common knowledge but I'd thought I would just share my findings.
It's hard to create a It would be amazing if there was a way to query/run that handler with less "raw" input parameters. For example, being able to run export function createApiGatewayHandler<TRouter extends AnyRouter>(
opts: CreateApiGatewayContextOptions<TRouter>,
) {
return async (event: APIGatewayProxyEvent) => {
const req = {
body: event.body,
method: event.httpMethod,
query: event.queryStringParameters,
headers: event.headers,
};
const path = event.path;
return await requestHandler({
...opts,
req: req as BaseRequest,
path,
});
};
} and then somehow let the adapter handle the response with json-body, headers and what not. |
Beta Was this translation helpful? Give feedback.
-
Would you be open to adding an API Gateway adapter? I haven't dived in deeply enough to the express and standalone ones to know exactly what it'd entail, but here's our current approach:
Which is fine, but we're relying on the
serverless-http
library to do all the magic hacks that make our entire backend work. And it doesn't feel right that we need express and serverless-http as prod dependencies at all, since API Gateway lambdas are actually already kind of closer to what trpc/server does in the first place, I think (just functions that take inputs and return promise outputs, rather than weirdres.status(...).send(...)
side-effects). How I imagine it could look:So I think it fits pretty neatly in alongside the other adapters. A simple API Gateway handler looks something like:
Beta Was this translation helpful? Give feedback.
All reactions