volks
volks
TtRPC
Created by volks on 4/18/2023 in #❓-help
Integrate third-party added endpoints into the router definition?
@Nick Lucas I know the Types, they're rather simplistic. how could I integrate those into the router?
9 replies
TtRPC
Created by volks on 4/18/2023 in #❓-help
Integrate third-party added endpoints into the router definition?
Yeah, I was just wondering if there was some TS magic that could be done to get the types into the router and have the TRPC call the endpoints. I guess I'll leave that aside for now
9 replies
TtRPC
Created by volks on 2/6/2023 in #❓-help
Cannot read properties of undefined (reading 'data') of res.error.data, when trpc errors out
I am running the latest version 10.10.0 This is the part from trpc that is erroring out
function getHTTPStatusCode(json) {
const arr = Array.isArray(json) ? json : [
json
];
const httpStatuses = new Set(arr.map((res)=>{
if ('error' in res) {
const data = res.error.data;
if (typeof data.httpStatus === 'number') {
return data.httpStatus;
}
const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
return getStatusCodeFromKey(code);
}
return 200;
}));
if (httpStatuses.size !== 1) {
return 207;
}
const httpStatus = httpStatuses.values().next().value;
return httpStatus;
}
function getHTTPStatusCode(json) {
const arr = Array.isArray(json) ? json : [
json
];
const httpStatuses = new Set(arr.map((res)=>{
if ('error' in res) {
const data = res.error.data;
if (typeof data.httpStatus === 'number') {
return data.httpStatus;
}
const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
return getStatusCodeFromKey(code);
}
return 200;
}));
if (httpStatuses.size !== 1) {
return 207;
}
const httpStatus = httpStatuses.values().next().value;
return httpStatus;
}
Here is my express trpc setup
export const trpc = initTRPC.context<Context>().create({
transformer: superjson,
errorFormatter: ({ error, type, path, input, ctx }) => {
const logger: Logger = Container.get("logger");
//TODO sentry or similar product for errors
logger.error("ERROR OCCURED: %o", error.message);
logger.error("ERROR DATA: %o", (error as any).data);
},
});

app.use(
"/trpc",
trpcExpress.createExpressMiddleware({
router: appRouter,
createContext: sessionContext,
})
);


const accountCreate = trpc.procedure
.input(
z.object({
email: z.string().min(1).email(),
})
)
.mutation(async ({ input }) => {

export const userRouter = trpc.router({
accountCreate,
})
export const trpc = initTRPC.context<Context>().create({
transformer: superjson,
errorFormatter: ({ error, type, path, input, ctx }) => {
const logger: Logger = Container.get("logger");
//TODO sentry or similar product for errors
logger.error("ERROR OCCURED: %o", error.message);
logger.error("ERROR DATA: %o", (error as any).data);
},
});

app.use(
"/trpc",
trpcExpress.createExpressMiddleware({
router: appRouter,
createContext: sessionContext,
})
);


const accountCreate = trpc.procedure
.input(
z.object({
email: z.string().min(1).email(),
})
)
.mutation(async ({ input }) => {

export const userRouter = trpc.router({
accountCreate,
})
Also not even sure about the zod error at the moment (not sure what is undefined, but thats for later debugging)
3 replies
TtRPC
Created by lukas on 10/26/2022 in #❓-help
NextJS 13 compability.
@lukinha There was Theos stream about this, trpc is working on Next13 but its still early
8 replies
TtRPC
Created by Ahmed Eid on 10/10/2022 in #❓-help
somehow when move typed function out of the router files, frontend infer type to be any ?
What exactly do you refer as typing is broken? I think I got the same issue and my types result to any I made a repo that reproduces my issue, not sure its the same https://stackoverflow.com/questions/74185198/typescript-losing-zod-and-trpc-types-across-monorepo-projects-types-result-in
9 replies
TtRPC
Created by volks on 10/12/2022 in #❓-help
Losing the type between the client and server
Inside packages/config are the tsconfig files and they all inherit from the base.json which defines the strict: true
24 replies
TtRPC
Created by volks on 10/12/2022 in #❓-help
Losing the type between the client and server
Hey @julius, tried my best to create a simple reproducible repository that reflects my issue. I added a readme that clarifies the issue further, here is the repo https://github.com/Nikola-Milovic/monorepo-trpc-issue I know this is a tall ask to check out but thank you nonetheless
24 replies
TtRPC
Created by volks on 10/12/2022 in #❓-help
Losing the type between the client and server
Yeah I'll try to get it reproduced and push it to gh
24 replies
TtRPC
Created by volks on 10/12/2022 in #❓-help
Losing the type between the client and server
Thats why I am super confused
24 replies
TtRPC
Created by volks on 10/12/2022 in #❓-help
Losing the type between the client and server
But the types are getting through to the client, just for some reason some types are lost and inferred to any
24 replies
TtRPC
Created by volks on 10/12/2022 in #❓-help
Losing the type between the client and server
Both are the same, strict mode is on
24 replies
TtRPC
Created by outis99 on 10/17/2022 in #❓-help
Mutation type issue
But I cant give you the exact implementation as I am not familiar with the technology unfortunately
39 replies
TtRPC
Created by outis99 on 10/17/2022 in #❓-help
Mutation type issue
Basically you can use a transaction and bulk insert all the cards and then update the column with the newly inserted cards
39 replies
TtRPC
Created by outis99 on 10/17/2022 in #❓-help
Mutation type issue
Are the cards in the column embedded or via a reference? Not sure how Prisma works or what driver youre using
39 replies
TtRPC
Created by outis99 on 10/17/2022 in #❓-help
Mutation type issue
But if it works great, update me if someone on the prisma side replies
39 replies
TtRPC
Created by outis99 on 10/17/2022 in #❓-help
Mutation type issue
Its a bit different from the code you listed above
39 replies