Chen
Chen
Explore posts from servers
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
TTCTheo's Typesafe Cult
Created by Matt on 1/19/2024 in #questions
useEffect, useState, and order of execution
Have you got an example of the code you've written, or something that resembles it? Happy to explain the order things happen in React but probably easier to explain in the context of what you're working with.
5 replies
TTCTheo's Typesafe Cult
Created by Chen on 1/18/2024 in #questions
Running TSC on tRPC client runs type checking on tRPC server
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
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
TTCTheo's Typesafe Cult
Created by Chen on 4/7/2023 in #questions
How can I 'sell' React to a workplace of dinosaur devs who hate javascript?
Update, it worked 😎
56 replies
TTCTheo's Typesafe Cult
Created by TheJhonny on 4/7/2023 in #questions
Tailwind or Chakra?
Definitely agree with most of the comments here, chakra has been really good for building quick small apps where I don’t really care about the styles. I’ve been using tailwind more recently for a bigger project though and the end result can look much better, it just takes a bit longer to get there.
45 replies
TTCTheo's Typesafe Cult
Created by Chen on 4/7/2023 in #questions
How can I 'sell' React to a workplace of dinosaur devs who hate javascript?
Anyway, thank you. Just bought accelerate 💀
56 replies
TTCTheo's Typesafe Cult
Created by Chen on 4/7/2023 in #questions
How can I 'sell' React to a workplace of dinosaur devs who hate javascript?
But yeah, going from support to no support is one of the reasons they're unsure. I just remind them that their entire product line is built on spring boot and they've never needed support for that.
56 replies
TTCTheo's Typesafe Cult
Created by Chen on 4/7/2023 in #questions
How can I 'sell' React to a workplace of dinosaur devs who hate javascript?
It does, but nobody uses it for some reason, ironically.
56 replies
TTCTheo's Typesafe Cult
Created by Chen on 4/7/2023 in #questions
How can I 'sell' React to a workplace of dinosaur devs who hate javascript?
I'm pretty sure it is. Not only are they paying a license fee to use a shitty framework, it was shitty at the peak of its popularity 10 years ago and they spend weeks training every new dev to use it themselves, because there is no educational content.
56 replies
TTCTheo's Typesafe Cult
Created by Chen on 4/7/2023 in #questions
How can I 'sell' React to a workplace of dinosaur devs who hate javascript?
This whole experience has been wild though, I've learned more in the last week just thinking about putting this argument forward than I have probably in the previous 2 years.
56 replies
TTCTheo's Typesafe Cult
Created by Chen on 4/7/2023 in #questions
How can I 'sell' React to a workplace of dinosaur devs who hate javascript?
No, but I've heard good things and have a long train journey tomorrow, so thanks for the reminder lol
56 replies
TTCTheo's Typesafe Cult
Created by Chen on 4/7/2023 in #questions
How can I 'sell' React to a workplace of dinosaur devs who hate javascript?
Yeah I've been pretty careful to not come across like I'm just mindlessly complaining because "old thing == bad", but I think because of my relative juniority they just expect that behaviour by default.
56 replies
TTCTheo's Typesafe Cult
Created by Chen on 4/7/2023 in #questions
How can I 'sell' React to a workplace of dinosaur devs who hate javascript?
That's the main reason I'm sticking around
56 replies