-
Notifications
You must be signed in to change notification settings - Fork 0
UUID issue fixed #24
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
UUID issue fixed #24
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||||||||||||
| import { prismaClient } from "@repo/db"; | ||||||||||||||||
| import { Express, Router } from "express"; | ||||||||||||||||
|
|
||||||||||||||||
| const router : Router = Router(); | ||||||||||||||||
|
|
||||||||||||||||
| router.post("/create" , async (req , res) =>{ | ||||||||||||||||
|
|
||||||||||||||||
| // const Data = req.body; | ||||||||||||||||
|
|
||||||||||||||||
| // const {name , email , password} = req.body | ||||||||||||||||
| // console.log(Data) | ||||||||||||||||
| try { | ||||||||||||||||
| const user = await prismaClient.user.create({ | ||||||||||||||||
| data : { | ||||||||||||||||
| name : "name", | ||||||||||||||||
| email : "email", | ||||||||||||||||
| password : "password" | ||||||||||||||||
| } | ||||||||||||||||
| }) | ||||||||||||||||
| res.json({ | ||||||||||||||||
| message : "Signup DOne", | ||||||||||||||||
| user | ||||||||||||||||
| }) | ||||||||||||||||
| } | ||||||||||||||||
| catch(e){ | ||||||||||||||||
| console.log("Detailed Error" , e) | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+25
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Send error response to client. The catch block logs the error but does not send a response, causing the client to hang indefinitely. Apply this diff: catch(e){
console.log("Detailed Error" , e)
+ res.status(500).json({ message: "Internal server error" })
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| }) | ||||||||||||||||
|
Comment on lines
+6
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's look at the full userRoutes.ts file to understand context
cat -n apps/http-backend/src/routes/userRoutes/userRoutes.tsRepository: Dev-Pross/BuildFlow Length of output: 947 🏁 Script executed: # Check if zod or joi is already in dependencies
cat apps/http-backend/package.json | grep -A 50 '"dependencies"'Repository: Dev-Pross/BuildFlow Length of output: 233 🏁 Script executed: # Search for UUID-related logic in the codebase to verify PR title accuracy
rg -i "uuid" --type ts --type js -nRepository: Dev-Pross/BuildFlow Length of output: 45 🏁 Script executed: # Look for other user creation or validation logic
rg -n "prismaClient.user.create"Repository: Dev-Pross/BuildFlow Length of output: 173 🏁 Script executed: # Check PR metadata to verify title and description
gh pr view --json title,body,filesRepository: Dev-Pross/BuildFlow Length of output: 135 🏁 Script executed: # Search entire repo for UUID-related logic across all packages
rg -i "uuid" -n --max-count 20Repository: Dev-Pross/BuildFlow Length of output: 936 Add input validation and verify PR scope alignment. The endpoint contains hardcoded credential strings instead of using request body values, and lacks email/password validation. Additionally, the PR title "UUID issue fixed" appears misaligned with this endpoint's changes—UUIDs in the codebase are handled automatically via Prisma's Required fixes:
Example validation approach: import { z } from 'zod';
const createUserSchema = z.object({
name: z.string().min(1),
email: z.string().email(),
password: z.string().min(8)
});
const validationResult = createUserSchema.safeParse(req.body);
if (!validationResult.success) {
return res.status(400).json({ message: "Invalid input", errors: validationResult.error });
}
const { name, email, password } = validationResult.data;
// use these in create()🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| export const userRouter = router ; | ||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"root":["./src/index.ts","./src/routes/nodes.routes.ts"],"version":"5.7.3"} | ||
| {"root":["./src/index.ts","./src/routes/nodes.routes.ts","./src/routes/userRoutes/userRoutes.ts"],"version":"5.7.3"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace hardcoded values and hash passwords before storage.
This endpoint has multiple critical issues:
"email"as a hardcoded value will cause a unique constraint violation on the second request if the email field has a unique constraint in your database schema.req.body, but the implementation uses hardcoded values instead.Apply this diff to use request body data and hash passwords:
Note: Ensure
express.json()middleware is configured inindex.tsto parse the request body.🤖 Prompt for AI Agents