Open baldanaresh opened 5 months ago
can u please provide your accounts file. above code does not have any kind of get request in account/balance.
Push the code to GitHub and send the repo link
Happy to check the issue and resolves it
Push the code to GitHub and send the repo link
Happy to check the issue and resolves it
Hi yesahem ,
I hope you're doing well. I have pushed the latest code to the repository. You can check it out here: https://github.com/baldanaresh/Paytm-basic.git
Thank you so much for your attention to this issue. Please take a look and let me know if you encounter any problems or have further questions.
Hey Naresh, So as I was going through your codebase I found that when a user is visiting the /api/v1/user/signup route it is not creating a Account in the db resulting no user account creation and if the account is not created then how balance can be shown to you...
I am pushing the code feel free to review it and merge it
For any query feel free to ping me on twitter : https://x.com/heyshishu Happy Coding ❤️
the error im getting is :SyntaxError: Unexpected end of JSON input at JSON.parse ()
at createStrictSyntaxError (C:\Users\nares\OneDrive\Desktop\Paytm\paytm\backend\node_modules\body-parser\lib\types\json.js:160:10)
at parse (C:\Users\nares\OneDrive\Desktop\Paytm\paytm\backend\node_modules\body-parser\lib\types\json.js:83:15)
at C:\Users\nares\OneDrive\Desktop\Paytm\paytm\backend\node_modules\body-parser\lib\read.js:128:18
at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
at invokeCallback (C:\Users\nares\OneDrive\Desktop\Paytm\paytm\backend\node_modules\raw-body\index.js:231:16)
at done (C:\Users\nares\OneDrive\Desktop\Paytm\paytm\backend\node_modules\raw-body\index.js:220:7)
at IncomingMessage.onEnd (C:\Users\nares\OneDrive\Desktop\Paytm\paytm\backend\node_modules\raw-body\index.js:280:7)
at IncomingMessage.emit (node:events:514:28)
at endReadableNT (node:internal/streams/readable:1359:12)
My code:const express=require("express"); const router=express.Router(); const zod=require("zod"); const {user}=require("../db"); const jwt=require("jsonwebtoken"); const {JWT_SEC}=require("../config"); const {authMiddleware}=require("../middleware")
const signupSchema=zod.object({ username:zod.string().email(), password:zod.string(), firstname:zod.string(), lastname:zod.string(), });
router.post("/signup",async(req,res)=>{ const body=req.body; const {success}=signupSchema.safeParse(req.body); if(!success){ return res.status(400).json({ message:" incorrect inputs" }) } const existingUser= await user.findOne({ username:body.username }) if(existingUser){ return res.status(409).json({ message:"Email already taken" }) }
});
const signinBody = zod.object({ username: zod.string().email(), password: zod.string() }) router.post("/signin",async(req,res)=>{ const body=req.body; const {success}=signinBody.safeParse(body); if(!success){ return res.status(400).json({ message:" incorrect inputs" }) } const userRecord = await user.findOne({ username: req.body.username, password: req.body.password });
}) const updateBody = zod.object({ password: zod.string().optional(), firstName: zod.string().optional(), lastName: zod.string().optional(), })
router.put("/", authMiddleware, async (req, res) => { const { success } = updateBody.safeParse(req.body) if (!success) { res.status(400).json({ message: "Error while updating information" }) }
}) router.get("/bulk", async (req, res) => { const filter = req.query.filter || "";
})
module.exports=router;