Skip to content

Commit

Permalink
perf: schema parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
rharkor committed Oct 30, 2023
1 parent 42fcbbc commit 9b4dcfd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/api/auth/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { emailVerificationExpiration } from "@/types/constants"
import { env } from "env.mjs"

export const register = async ({ input }: apiInputFromSchema<typeof signUpSchema>) => {
const { email, password, username } = signUpSchema().parse(input)
const { email, password, username } = input
try {
const hashedPassword = await hash(password, 12)

Expand Down
4 changes: 2 additions & 2 deletions src/api/me/email/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { env } from "env.mjs"

export const sendVerificationEmail = async ({ input }: apiInputFromSchema<typeof sendVerificationEmailSchema>) => {
try {
const { email, silent } = sendVerificationEmailSchema().parse(input)
const { email, silent } = input

const token = randomUUID()
const user = await prisma.user.findUnique({
Expand Down Expand Up @@ -86,7 +86,7 @@ export const sendVerificationEmail = async ({ input }: apiInputFromSchema<typeof

export const verifyEmail = async ({ input }: apiInputFromSchema<typeof verifyEmailSchema>) => {
try {
const { token } = verifyEmailSchema().parse(input)
const { token } = input

const userEmailVerificationToken = await prisma.userEmailVerificationToken.findUnique({
where: {
Expand Down
2 changes: 1 addition & 1 deletion src/api/me/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { rolesAsObject } from "@/types/constants"
export const updateUser = async ({ input, ctx: { session } }: apiInputFromSchema<typeof updateUserSchema>) => {
ensureLoggedIn(session)
try {
const { username } = updateUserSchema().parse(input)
const { username } = input
//* Update the user
const user = await prisma.user.update({
where: { id: session.user.id },
Expand Down
4 changes: 2 additions & 2 deletions src/api/me/password/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { env } from "env.mjs"

export const forgotPassword = async ({ input }: apiInputFromSchema<typeof forgotPasswordSchema>) => {
try {
const { email } = forgotPasswordSchema().parse(input)
const { email } = input
//? Check if user exists
const user = await prisma.user.findUnique({
where: {
Expand Down Expand Up @@ -74,7 +74,7 @@ export const forgotPassword = async ({ input }: apiInputFromSchema<typeof forgot

export const resetPassword = async ({ input }: apiInputFromSchema<typeof resetPasswordSchema>) => {
try {
const { token, password } = resetPasswordSchema().parse(input)
const { token, password } = input
const resetPassordToken = await prisma.resetPassordToken.findUnique({
where: {
token,
Expand Down
2 changes: 1 addition & 1 deletion src/api/me/sessions/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { apiInputFromSchema } from "@/types"
export const deleteSession = async ({ input, ctx: { session } }: apiInputFromSchema<typeof deleteSessionSchema>) => {
try {
ensureLoggedIn(session)
const { id, sessionToken } = deleteSessionSchema().parse(input)
const { id, sessionToken } = input
//* Delete session
const deletedSession = await prisma.session.delete({
where: {
Expand Down

0 comments on commit 9b4dcfd

Please sign in to comment.