ferdy
ferdy
Explore posts from servers
TtRPC
Created by ferdy on 7/19/2023 in #❓-help
trpc client request size limits?
the request never makes it to the server, so somewhere the trpc client is trying to parse the request for some reason and i think having it too big makes it introduce a funky token?
2 replies
TtRPC
Created by ferdy on 5/4/2023 in #❓-help
Get tRPC procedure latency?
a middleware will only run before a procedure right?
7 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
i do everything through cdk, specifically using NodejsFunction
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
ohh no it wasnt. I didn't do the initial setup of this codebase, didn't even notice strict wasnt on. Enabling strict mode and removing the extra <Context> works, compile-wise -- not sure yet about runtime
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
also fixed having to supply a transformer
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
ok I got it working -- truly dont understand this yet but adding Context to the type parameter of create did the trick:
export const createContext = ({event, context}: CreateAWSLambdaContextOptions<APIGatewayProxyEventV2>) => ({});
type Context = inferAsyncReturnType<typeof createContext>;

const t = initTRPC.context<Context>().create<Context>();
export const createContext = ({event, context}: CreateAWSLambdaContextOptions<APIGatewayProxyEventV2>) => ({});
type Context = inferAsyncReturnType<typeof createContext>;

const t = initTRPC.context<Context>().create<Context>();
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
it definitely could be an apig oddity, though I can see it in the console returning the json response correctly. Maybe I need to find somewhere in between that I can inspect to see where that response is getting lost... Like a debug log from the trpc client or something
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
it's just the return value isn't getting processed correctly
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
yep. and I tested out calling the api directly in my aws console, confirmed its working. Also confirmed that the lambda is getting invoked when I call it from the client by double checking logs
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
I was able to pass in superjson and get around the error, but then the response from my lambda was coming back undefined -- I was wondering if the default transformer would've just handled the response correctly
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
no luck with that
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
ok ill search around as well
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
"@trpc/server": "^10.14.0",
"@trpc/client": "^10.14.0",
"@trpc/server": "^10.14.0",
"@trpc/client": "^10.14.0",
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
TS2345: Argument of type '{ links: TRPCLink<CreateRouterInner<RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>, { testRoute: BuildProcedure<"query", { _config: RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>; ... 5 more ...; _meta: object; }, { ...; ...' is not assignable to parameter of type 'CreateTRPCClientOptions<CreateRouterInner<RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>, { testRoute: BuildProcedure<"query", { _config: RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>; ... 5 more ...; _meta: object; }, {...'.   Property 'transformer' is missing in type '{ links: TRPCLink<CreateRouterInner<RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>, { testRoute: BuildProcedure<"query", { _config: RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>; ... 5 more ...; _meta: object; }, { ...; ...' but required in type '{ transformer: DataTransformerOptions; }'.
TS2345: Argument of type '{ links: TRPCLink<CreateRouterInner<RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>, { testRoute: BuildProcedure<"query", { _config: RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>; ... 5 more ...; _meta: object; }, { ...; ...' is not assignable to parameter of type 'CreateTRPCClientOptions<CreateRouterInner<RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>, { testRoute: BuildProcedure<"query", { _config: RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>; ... 5 more ...; _meta: object; }, {...'.   Property 'transformer' is missing in type '{ links: TRPCLink<CreateRouterInner<RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>, { testRoute: BuildProcedure<"query", { _config: RootConfig<{ ctx: {}; meta: object; errorShape: never; transformer: DataTransformerOptions; }>; ... 5 more ...; _meta: object; }, { ...; ...' but required in type '{ transformer: DataTransformerOptions; }'.
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
export const createContext = (_: CreateAWSLambdaContextOptions<APIGatewayProxyEventV2>) => ({});
type Context = inferAsyncReturnType<typeof createContext>;

const t = initTRPC.context<Context>().create();

export const middleware = t.middleware;
export const router = t.router;
export const procedure = t.procedure;
export const mergeRouters = t.mergeRouters;

const appRouter = router({
testRoute: procedure.query(async () => {
// mock fast db lookup
await new Promise((res) => setTimeout(res, 100));

return {
value: 5,
};
}),
testRoute2: procedure.query(async () => {
await new Promise((res) => setTimeout(res, 100));

return {
obj: {
value: 10,
},
};
}),
});

export const handler = awsLambdaRequestHandler({
router: appRouter,
createContext,
});

export type AppRouter = typeof appRouter;
export const createContext = (_: CreateAWSLambdaContextOptions<APIGatewayProxyEventV2>) => ({});
type Context = inferAsyncReturnType<typeof createContext>;

const t = initTRPC.context<Context>().create();

export const middleware = t.middleware;
export const router = t.router;
export const procedure = t.procedure;
export const mergeRouters = t.mergeRouters;

const appRouter = router({
testRoute: procedure.query(async () => {
// mock fast db lookup
await new Promise((res) => setTimeout(res, 100));

return {
value: 5,
};
}),
testRoute2: procedure.query(async () => {
await new Promise((res) => setTimeout(res, 100));

return {
obj: {
value: 10,
},
};
}),
});

export const handler = awsLambdaRequestHandler({
router: appRouter,
createContext,
});

export type AppRouter = typeof appRouter;
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
yeah
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
^^^ this doesnt compile
55 replies
TtRPC
Created by ferdy on 3/6/2023 in #❓-help
trpc + AWS Lambda (through cdk)
const client = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: "https://xxxxxxxx.execute-api.us-west-2.amazonaws.com/prod/"
})
],
});
const client = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: "https://xxxxxxxx.execute-api.us-west-2.amazonaws.com/prod/"
})
],
});
55 replies