Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/remove unused "me" update endpoint #929

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions apps/studio/src/schemas/me.ts

This file was deleted.

47 changes: 0 additions & 47 deletions apps/studio/src/server/modules/me/me.router.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import { Prisma } from "@prisma/client"
import { TRPCError } from "@trpc/server"
import { z } from "zod"

import { updateMeSchema } from "~/schemas/me"
import { protectedProcedure, router } from "~/server/trpc"
import { defaultMeSelect } from "./me.select"

Expand All @@ -13,46 +8,4 @@ export const meRouter = router({
select: defaultMeSelect,
})
}),
// TODO: Remove in future PRs since this is unused
updateAvatar: protectedProcedure
.input(
z.object({
imageKey: z.string().nullish(),
}),
)
.mutation(async ({ ctx }) => {
return ctx.prisma.user.update({
where: { id: ctx.user.id },
data: {},
select: defaultMeSelect,
})
}),
// TODO: Remove in future PRs since this is unused
update: protectedProcedure
.input(updateMeSchema)
.mutation(async ({ ctx, input }) => {
try {
return await ctx.prisma.user.update({
where: { id: ctx.user.id },
data: input,
select: defaultMeSelect,
})
} catch (e) {
if (e instanceof Prisma.PrismaClientKnownRequestError) {
if (e.code === "P2002") {
ctx.logger.info("Username conflict", {
userId: ctx.user.id,
chosen: input.username,
})

throw new TRPCError({
message: "That username has been taken. Please choose another.",
code: "CONFLICT",
cause: e,
})
}
}
throw e
}
}),
})
Loading