Chen
Chen
TtRPC
Created by Chen on 9/22/2024 in #❓-help
Is it possible to change the base path?
For what it's worth, I've done this as a workaround:
// functions/.../index.ts
const trpcHandler = awsLambdaRequestHandler({
router: appRouter,
createContext: createTrpcContext,
});

export const handler: APIGatewayProxyHandlerV2 = async (event, context) => {
if (event.rawPath.startsWith("/trpc")) {
event.rawPath = event.rawPath.slice(5);
if (event.rawPath === "") {
event.rawPath = "/";
}
}

if (event.requestContext?.http?.path) {
event.requestContext.http.path = event.rawPath;
}

return trpcHandler(event, context);
};
// functions/.../index.ts
const trpcHandler = awsLambdaRequestHandler({
router: appRouter,
createContext: createTrpcContext,
});

export const handler: APIGatewayProxyHandlerV2 = async (event, context) => {
if (event.rawPath.startsWith("/trpc")) {
event.rawPath = event.rawPath.slice(5);
if (event.rawPath === "") {
event.rawPath = "/";
}
}

if (event.requestContext?.http?.path) {
event.requestContext.http.path = event.rawPath;
}

return trpcHandler(event, context);
};
3 replies
TtRPC
Created by Chen on 9/22/2024 in #❓-help
Is it possible to change the base path?
I'm using the awsLambdaRequestHandler from @trpc/server/adapters/aws-lambda:
// functions/.../index.ts
export const handler = awsLambdaRequestHandler({
router: appRouter,
createContext: createTrpcContext,
});
// functions/.../index.ts
export const handler = awsLambdaRequestHandler({
router: appRouter,
createContext: createTrpcContext,
});
And SST:
// sst.config.ts
export const trpc = new sst.aws.Function("Api", {
handler: "packages/functions/src/api/index.handler",
runtime: "nodejs20.x",
memory: "128 MB",
link: [database, auth],
url: true,
});

export const apiRouter = new sst.aws.Router("ApiRouter", {
domain: {
name: "api." + domain,
dns: sst.cloudflare.dns(),
},
routes: {
"/trpc/*": trpc.url,
},
});
// sst.config.ts
export const trpc = new sst.aws.Function("Api", {
handler: "packages/functions/src/api/index.handler",
runtime: "nodejs20.x",
memory: "128 MB",
link: [database, auth],
url: true,
});

export const apiRouter = new sst.aws.Router("ApiRouter", {
domain: {
name: "api." + domain,
dns: sst.cloudflare.dns(),
},
routes: {
"/trpc/*": trpc.url,
},
});
3 replies
TtRPC
Created by Chen on 1/17/2024 in #❓-help
Client `tsc` checking server code
See this repo for an example of the issue I'm having: https://github.com/bchilcott/trpc-ts-problem
3 replies
TtRPC
Created by Chen on 1/17/2024 in #❓-help
Client `tsc` checking server code
I realise this isn’t directly a trpc problem but I’m hoping someone here has run into the same thing
3 replies
TtRPC
Created by mh15 on 12/4/2023 in #❓-help
`The property 'query' in your router collides with a built-in method`
Does seem to be tsconfig themed for sure. I have a pretty basic set up, no craziness happening with paths besides what I sent above.
11 replies
TtRPC
Created by mh15 on 12/4/2023 in #❓-help
`The property 'query' in your router collides with a built-in method`
To clarify this if anyone is looking in the future, I have the following server/src/utils/trpc.ts:
import { initTRPC } from "@trpc/server";
export const t = initTRPC.create()`
import { initTRPC } from "@trpc/server";
export const t = initTRPC.create()`
And in server/src/app.ts...
import { t } from "~/utils/trpc" // this causes the error
import { t } from "./utils/trpc" // this has resolved it
import { t } from "~/utils/trpc" // this causes the error
import { t } from "./utils/trpc" // this has resolved it
My tsconfig looks like this:
// ...
"paths": {
"~/*": ["./src/*"]
}
// ...
"paths": {
"~/*": ["./src/*"]
}
11 replies
TtRPC
Created by Chen on 1/17/2024 in #❓-help
Can you ensureData without the useUtils hook?
Thanks - is it createTRPCQueryUtils?
5 replies