Kirik
Kirik
TTCTheo's Typesafe Cult
Created by Kirik on 8/5/2023 in #questions
'id' does not exist in type 'UseTRPCMutationOptions<{ id: string; title?: string | undefined; ...
Thanks! Javascript sure has a way of doing things. I appreciate the help 🙏
7 replies
TTCTheo's Typesafe Cult
Created by Kirik on 5/4/2023 in #questions
Type 'string | null' is not assignable to type 'string | undefined'.
update: privateProcedure
.input(
z.object({
id: z.string(),
title: z.string().min(1).max(280).optional(),
rating: z.number().min(1).max(5).optional(),
rating_denominator: z.number().min(1).optional(),
reward_xp: z.number().min(1).optional(),
goal: z.string().optional(),
target: z.date().optional(),
description: z.string().optional(),
region: z.string().optional(),
location: z.string().optional(),
imageUrl: z.string().optional(),
tagline: z.string().optional(),
ingredients: z.string().optional(),
reward: z.string().optional(),
objectives: z.array(
z.object({
obj: z.string(),
location: z.string(),
ingredients: z.string(),
requiredAmount: z.number(),
})
).optional(),
})
)
.mutation(async ({ ctx, input }) => {
const authorId = ctx.userId;

const { success } = await ratelimit.limit(authorId);

if (!success) throw new TRPCError({ code: "TOO_MANY_REQUESTS" });

const quest = await ctx.prisma.quest.update({
where: { id: input.id },
data: {
title: input.title,
rating: input.rating,
rating_denominator: input.rating_denominator,
reward_xp: input.reward_xp,
goal: input.goal,
target: input.target,
description: input.description,
region: input.region,
location: input.location,
imageUrl: input.imageUrl,
tagline: input.tagline,
ingredients: input.ingredients,
reward: input.reward,

},

});
/* const objectives = await ctx.prisma.objective.update({data: {create:
{obj :input.objectives}); */
if (!quest) throw new TRPCError({ code: "NOT_FOUND" });

return (await addUserDataToQuests([quest]))[0];

}),
update: privateProcedure
.input(
z.object({
id: z.string(),
title: z.string().min(1).max(280).optional(),
rating: z.number().min(1).max(5).optional(),
rating_denominator: z.number().min(1).optional(),
reward_xp: z.number().min(1).optional(),
goal: z.string().optional(),
target: z.date().optional(),
description: z.string().optional(),
region: z.string().optional(),
location: z.string().optional(),
imageUrl: z.string().optional(),
tagline: z.string().optional(),
ingredients: z.string().optional(),
reward: z.string().optional(),
objectives: z.array(
z.object({
obj: z.string(),
location: z.string(),
ingredients: z.string(),
requiredAmount: z.number(),
})
).optional(),
})
)
.mutation(async ({ ctx, input }) => {
const authorId = ctx.userId;

const { success } = await ratelimit.limit(authorId);

if (!success) throw new TRPCError({ code: "TOO_MANY_REQUESTS" });

const quest = await ctx.prisma.quest.update({
where: { id: input.id },
data: {
title: input.title,
rating: input.rating,
rating_denominator: input.rating_denominator,
reward_xp: input.reward_xp,
goal: input.goal,
target: input.target,
description: input.description,
region: input.region,
location: input.location,
imageUrl: input.imageUrl,
tagline: input.tagline,
ingredients: input.ingredients,
reward: input.reward,

},

});
/* const objectives = await ctx.prisma.objective.update({data: {create:
{obj :input.objectives}); */
if (!quest) throw new TRPCError({ code: "NOT_FOUND" });

return (await addUserDataToQuests([quest]))[0];

}),
7 replies
TTCTheo's Typesafe Cult
Created by Kirik on 4/27/2023 in #questions
Custom Nested DB schema defaults or empty help
create: privateProcedure .input( z.object({ content: z.string().emoji("Only emojis are allowed").min(1).max(280), }) ) .mutation(async ({ ctx, input }) => { const authorId = ctx.userId;
const { success } = await ratelimit.limit(authorId);
if (!success) throw new TRPCError({ code: "TOO_MANY_REQUESTS" });
const quest = await ctx.prisma.quest.create({
data: { authorId, title: input.content, rating: 1, rating_denominator:1, reward_xp:1, goal: "goal", target: new Date(), description: "description",


}, });
return quest; }),
3 replies
TTCTheo's Typesafe Cult
Created by Kirik on 4/26/2023 in #questions
:x: tRPC failed on posts.create: Unauthorized -- from T3 Stack Tutorial tutorial
Solved! Except for the styles :/
6 replies
TTCTheo's Typesafe Cult
Created by Kirik on 4/26/2023 in #questions
:x: tRPC failed on posts.create: Unauthorized -- from T3 Stack Tutorial tutorial
AHA It was invalid upstash credentials. my token was set to masked * and not the actual secret
6 replies
TTCTheo's Typesafe Cult
Created by Kirik on 4/26/2023 in #questions
:x: tRPC failed on posts.create: Unauthorized -- from T3 Stack Tutorial tutorial
narrowed it down to const { success } = await ratelimit.limit(authorId);
6 replies