Nicolas
Nicolas
Explore posts from servers
TtRPC
Created by Nicolas on 2/16/2024 in #❓-help
No "mutation"-procedure on path
My app router is like this:
const myAppRouter = router({
organizationRouter: OrganizationRouter
});

export type AppRouter = typeof OrganizationRouter;

export const handler = awsLambdaRequestHandler({
router: myAppRouter,
createContext,
});
const myAppRouter = router({
organizationRouter: OrganizationRouter
});

export type AppRouter = typeof OrganizationRouter;

export const handler = awsLambdaRequestHandler({
router: myAppRouter,
createContext,
});
3 replies
TtRPC
Created by Nicolas on 2/16/2024 in #❓-help
No "mutation"-procedure on path
This is how I am using the mutation on the server-side:
export const OrganizationRouter = router({
insert_superUser: authRoleProcedure.meta({ role: Role.SuperUser })
.input(NewOrganization)
.output(z.object({
success: z.boolean(),
message: z.string().optional(),
}))
.mutation(async ({ input }) => {
const response = await db.insert(Organization).values(input).returning();
if (response[0].id) {
return {
success: true,
};
}
return {
success: false,
message: "Organization not inserted",
};
}),
})
export const OrganizationRouter = router({
insert_superUser: authRoleProcedure.meta({ role: Role.SuperUser })
.input(NewOrganization)
.output(z.object({
success: z.boolean(),
message: z.string().optional(),
}))
.mutation(async ({ input }) => {
const response = await db.insert(Organization).values(input).returning();
if (response[0].id) {
return {
success: true,
};
}
return {
success: false,
message: "Organization not inserted",
};
}),
})
3 replies
TtRPC
Created by Nicolas on 11/17/2023 in #❓-help
Creating inner context for AWS Lambda Context Options
It seems that I somehow need to tell all my exising code that a user will exist if called from the API, but not for internal calls, I am confused on how this is solved with the example online: https://trpc.io/docs/server/context#inner-and-outer-context All they do is:
return {
...contextInner,
req: opts.req,
res: opts.res,
};
return {
...contextInner,
req: opts.req,
res: opts.res,
};
And I did something similar, but since we are defining export type Context = inferAsyncReturnType<typeof createContextInner>;, I don't see how it ever knows about the req and res, and thus there are errors everywhere
5 replies
TtRPC
Created by Nicolas on 9/30/2023 in #❓-help
Basic Inference not Working
It works if I do the following:
list: adminProcedure.query(async () => {
const response = await listOrganizations.all();
return response as Organization[];
}),
list: adminProcedure.query(async () => {
const response = await listOrganizations.all();
return response as Organization[];
}),
But shouldn't trpc be able to inference it fine without having to force the output type? Seems like it defeats the point of trpc if I have to do that...
3 replies
TtRPC
Created by Nicolas on 8/31/2023 in #❓-help
Issue Inferring Type on Frontend with ElectroDB Query Return Statement
No description
3 replies