itelofilho
itelofilho
Explore posts from servers
TTCTheo's Typesafe Cult
Created by itelofilho on 6/10/2024 in #questions
FatalError: error TS6053: File '@acme/tsconfig/base.json' not found.
is anyone else encountering issues with the create-t3-turbo? It looks like Vercel has switched to using turbo 2.x, and it's causing problems with my old setup (which I forked 6 months ago). Most of it works fine, but I'm getting a FatalError: error TS6053: File @acme/tsconfig/base.json' not found. on the Vercel CI.
2 replies
TtRPC
Created by itelofilho on 3/20/2024 in #❓-help
Is it possible to perform attribute-based authorization after the .query?
I have a TRPC method, getStudentGradeById, that accepts the gradeId. I want to return the grade only if the student owns it. the current code is:
protectecProcedure
.input(z.object({
gradeId: z.string()
}))
.query(({ input: {gradeId}, ctx}) => {
const grade = prisma.grade.findById(gradeId)
if (result.studentId !== ctx.studentId) {
throw new Error()
}
})
protectecProcedure
.input(z.object({
gradeId: z.string()
}))
.query(({ input: {gradeId}, ctx}) => {
const grade = prisma.grade.findById(gradeId)
if (result.studentId !== ctx.studentId) {
throw new Error()
}
})
I want something like:
protectecProcedure
.input(z.object({
gradeId: z.string()
}))
.query(() => prisma.grade.findById(gradeId))
.use((ctx, result) => {
if (result.studentId !== ctx.studentId) {
throw new Error()
}
})
protectecProcedure
.input(z.object({
gradeId: z.string()
}))
.query(() => prisma.grade.findById(gradeId))
.use((ctx, result) => {
if (result.studentId !== ctx.studentId) {
throw new Error()
}
})
I don't want to use the output because it would require me to write the output schema for each method. Additionally, I don't want to include any permission management within the .query. Is it possible to achieve this? Should I attempt to make the necessary changes and submit a pull request?
6 replies