Skip to content

Commit

Permalink
fix: Prettier lint
Browse files Browse the repository at this point in the history
  • Loading branch information
weslley17w committed Dec 2, 2023
1 parent e956bba commit 1ff1ba7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 98 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"editor.formatOnSave": true, // optional
"editor.formatOnSaveMode": "file", // required to format on save
"files.autoSave": "onFocusChange", // optional but recommended
"vs-code-prettier-eslint.prettierLast": true // set as "true" to run 'prettier' last not first
"vs-code-prettier-eslint.prettierLast": true,
"[typescript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
} // set as "true" to run 'prettier' last not first
}
2 changes: 1 addition & 1 deletion backend/src/controllers/classPlanController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ export default class classPlanController {
}
}
}
}
}
9 changes: 4 additions & 5 deletions backend/src/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,20 @@ export default class userController {
})
res.status(201).json(data)
} catch (err) {
let inputErr: { email?: string; username?: string } = {}
if (err instanceof ZodError) {
res.status(400).json(fromZodError(err))
} else if (err instanceof Prisma.PrismaClientKnownRequestError) {
err as Prisma.PrismaClientKnownRequestError
const b = err.meta?.target as string[] | undefined
let inputErr: { email?: string; username?: string } = {}

if (b?.includes("email")) inputErr = { email: "Invalid email" }

if (b?.includes("username"))
inputErr = { username: "Username already exists" }

if (inputErr) res.status(400).json({ errors: inputErr })
}
res.status(500).json({ errors: { server: "Server error" } })

if (inputErr) res.status(400).json({ errors: inputErr })
else res.status(500).json({ errors: { server: "Server error" } })
}
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/zodSchemas/classPlan.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ const classPlanSchema = z.object({
userId: z.string().uuid("Id do usuário inválido"),
})

export { classPlanSchema }
export { classPlanSchema }
Loading

0 comments on commit 1ff1ba7

Please sign in to comment.