Skip to content

Commit

Permalink
fix: no loger checking trpc context.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezeikel committed Jan 3, 2025
1 parent e764020 commit 12e197b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/api/router/device.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { z } from "zod";
import { db } from "@cuurly/db";
import { publicProcedure } from "../trpc";

export default {
Expand All @@ -10,14 +11,17 @@ export default {
testUserId: z.string().optional(),
}),
)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.mutation(async ({ ctx, input }) => {
const userId = ctx.userId || input.testUserId;
// TODO: add userId to trpc context
// const userId = ctx.userId || input.testUserId;
const userId = input.testUserId;

if (!userId) {
throw new Error("No user ID provided");
}

const existingDevice = await ctx.db.device.findFirst({
const existingDevice = await db.device.findFirst({
where: {
userId,
token: input.fcmToken,
Expand All @@ -28,7 +32,7 @@ export default {
return existingDevice;
}

return ctx.db.device.create({
return db.device.create({
data: {
token: input.fcmToken,
userId,
Expand Down

0 comments on commit 12e197b

Please sign in to comment.