rd
rd
Explore posts from servers
TtRPC
Created by rd on 6/9/2023 in #❓-help
All values in DecoratedProcedureRecord are of type any
Hey thanks, yes separate package.json files, using turborepo and npm workspaces (I think), all dependencies are installed in the root node_modules dir. I'll see if adding the server file to "include" helps, appreciate the advice 🙂
12 replies
TtRPC
Created by rd on 6/9/2023 in #❓-help
All values in DecoratedProcedureRecord are of type any
Not sure if this is clear or not! Appreciate the help but no pressure of course 🙂
tsconfig.json
- apps
- client
- tsconfig.json
- server
- tsconfig.json
tsconfig.json
- apps
- client
- tsconfig.json
- server
- tsconfig.json
root tsconfig:
{
"files": [],
"references": [
{
"path": "./apps/server"
},
{
"path": "./apps/client"
},
]
}
{
"files": [],
"references": [
{
"path": "./apps/server"
},
{
"path": "./apps/client"
},
]
}
server tsconfig:
{
"compilerOptions": {
"baseUrl": ".",
"composite": false,
"declaration": false,
"declarationMap": false,
"esModuleInterop": true,
"inlineSources": false,
"isolatedModules": true,
"module": "CommonJS",
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"outDir": "./dist",
"rootDir": "./src",
"skipLibCheck": true,
"strict": true,
"target": "ES2022",
"types": ["vitest/globals", "node"],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"],
"exclude": ["node_modules", "src/**/*.spec.ts", "src/**/*.test.ts"],
"ts-node": {
"require": ["tsconfig-paths/register"],
"transpileOnly": false
}
}
{
"compilerOptions": {
"baseUrl": ".",
"composite": false,
"declaration": false,
"declarationMap": false,
"esModuleInterop": true,
"inlineSources": false,
"isolatedModules": true,
"module": "CommonJS",
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"outDir": "./dist",
"rootDir": "./src",
"skipLibCheck": true,
"strict": true,
"target": "ES2022",
"types": ["vitest/globals", "node"],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"],
"exclude": ["node_modules", "src/**/*.spec.ts", "src/**/*.test.ts"],
"ts-node": {
"require": ["tsconfig-paths/register"],
"transpileOnly": false
}
}
client tsconfig:
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"lib": ["ES2016", "DOM", "DOM.Iterable"]
}
}
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"lib": ["ES2016", "DOM", "DOM.Iterable"]
}
}
12 replies
TtRPC
Created by rd on 6/9/2023 in #❓-help
All values in DecoratedProcedureRecord are of type any
I can if it would be helpful, anything specifically? I'm certain this isn't a tRPC issue now though, I removed path aliases from the internal package/tsconfig and the types reappeared.
12 replies
TtRPC
Created by rd on 6/9/2023 in #❓-help
All values in DecoratedProcedureRecord are of type any
Ah, I think it's related to using paths in a ts-config in a monorepo, seems like the consuming package potentially can't resolve the imports
12 replies
TtRPC
Created by rd on 6/9/2023 in #❓-help
All values in DecoratedProcedureRecord are of type any
I've tried stripping down the router to a single merge with one procedure though and it's still of type any 🤷‍♂️
12 replies
TtRPC
Created by rd on 4/24/2023 in #❓-help
Error Handling vs Error Formatting
Great, thanks for clarifying!
8 replies
TtRPC
Created by rd on 4/24/2023 in #❓-help
Error Handling vs Error Formatting
e.g. I could do something like this, but I'm sure there is a better way? Like throwing a new TRPCError somewhere internally between my procedure and the formatter?
import { CustomOrmError, NotFoundError } from 'custom-orm';
import { TRPC_ERROR_CODES_BY_KEY } from '@trpc/server/dist/rpc';

const errorFormatter = ({ shape, error }) => {
if (error.cause instanceof CustomOrmError) {
if (error.cause instanceof NotFoundError) {
return {
message: 'Not found',
code: TRPC_ERROR_CODES_BY_KEY['NOT_FOUND'],
data: {
code: 'NOT_FOUND',
httpStatus: 404,
},
};
}
return {
message: 'Something went wrong...',
code: TRPC_ERROR_CODES_BY_KEY['INTERNAL_SERVER_ERROR'],
data: {
code: 'INTERNAL_SERVER_ERROR',
httpStatus: 500,
},
};
}
return shape;
}
import { CustomOrmError, NotFoundError } from 'custom-orm';
import { TRPC_ERROR_CODES_BY_KEY } from '@trpc/server/dist/rpc';

const errorFormatter = ({ shape, error }) => {
if (error.cause instanceof CustomOrmError) {
if (error.cause instanceof NotFoundError) {
return {
message: 'Not found',
code: TRPC_ERROR_CODES_BY_KEY['NOT_FOUND'],
data: {
code: 'NOT_FOUND',
httpStatus: 404,
},
};
}
return {
message: 'Something went wrong...',
code: TRPC_ERROR_CODES_BY_KEY['INTERNAL_SERVER_ERROR'],
data: {
code: 'INTERNAL_SERVER_ERROR',
httpStatus: 500,
},
};
}
return shape;
}
8 replies
TtRPC
Created by rd on 4/6/2023 in #❓-help
Throwing fastify errors when using fastify adapter
Ace, I assumed as much and went ahead and did something similar earlier, but good to have confirmation. It's sometimes difficult to know with adapters which part to prioritise so just wanted some clarification, thanks!
4 replies
TtRPC
Created by rd on 2/23/2023 in #❓-help
JSON inferred router output not matching
Thanks for your help and sorry for not trying that sooner
11 replies
TtRPC
Created by rd on 2/23/2023 in #❓-help
JSON inferred router output not matching
So likely Prisma related and tRPC is doing everything correctly 👍
11 replies
TtRPC
Created by rd on 2/23/2023 in #❓-help
JSON inferred router output not matching
I think it may have been Prisma creating some kind of deeply recursive type that maybe the server wasn't dealing with for whatever reason? I'm seeing Type instantiation is excessively deep and possibly infinite. when I try to access that value now.
11 replies
TtRPC
Created by rd on 2/23/2023 in #❓-help
JSON inferred router output not matching
Hmm, I just reset my TS server and I think it's updated, my apologies.
11 replies
TtRPC
Created by rd on 2/23/2023 in #❓-help
JSON inferred router output not matching
Yes I believe strict is enabled everywhere
11 replies