Skip to content
Snippets Groups Projects
Commit 9a4d8ecb authored by Zaman, Orangzaib (UG - Computer Science)'s avatar Zaman, Orangzaib (UG - Computer Science)
Browse files

Implemented signup route for users sign up request

parent 4abc3448
No related branches found
No related tags found
2 merge requests!8CI/CD,!3Users service
...@@ -28,7 +28,19 @@ export const signin = async (req, res) => { ...@@ -28,7 +28,19 @@ export const signin = async (req, res) => {
} }
export const signup = async (req, res) => { export const signup = async (req, res) => {
const { name, email, password } = req.body;
try {
const existingUser = await User.findOne({ email });
if (existingUser) {
return res.status(400).json({ message: "User already exists" });
}
const user = await User.create({ name, email, password });
return res.status(200).json(user);
} catch (error) {
return res.status(500).json({ message: "Something went wrong" });
}
} }
export const checkUserEmail = async (req, res) => { export const checkUserEmail = async (req, res) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment