diff --git a/client/src/template/RegisterPage.tsx b/client/src/template/RegisterPage.tsx index 7a346ab..1eb086c 100644 --- a/client/src/template/RegisterPage.tsx +++ b/client/src/template/RegisterPage.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ "use client"; import { useState } from "react"; @@ -20,9 +21,13 @@ export default function RegisterPage() { try { await API.post("/api/auth/register", registerData); + router.push("/login"); - } catch (error) { - console.error("Registration failed", error); + } catch (error: any) { + if (error.response) { + console.error("Registration failed", error.response.data); + } + console.error("Registration failed", error.message); } }; diff --git a/server/package.json b/server/package.json index e1ba15e..02cbea1 100644 --- a/server/package.json +++ b/server/package.json @@ -3,7 +3,6 @@ "version": "1.0.0", "description": "", "main": "index.js", - "type":"module", "scripts": { "dev": "nodemon src/server.ts", "test": "jest", diff --git a/server/src/routes/authRoutes.ts b/server/src/routes/authRoutes.ts index fdcc0d7..ee37ff7 100644 --- a/server/src/routes/authRoutes.ts +++ b/server/src/routes/authRoutes.ts @@ -17,7 +17,12 @@ router.post("/register", async (req: Request, res: Response): Promise => { const newUser = new UserModel({ username, email, password }); await newUser.save(); + + res + .status(200) + .json({ message: "User registered successfully", user: newUser }); } catch (error) { + console.error("Registeration error:", error); res.status(500).json({ message: "Registration failed" }); } }); diff --git a/server/tsconfig.json b/server/tsconfig.json index fbfbe6f..e074a31 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { - "target": "es6", - "module": "commonjs", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "outDir": "./dist" + "target": "ES2020", + "module": "CommonJS", + "strict": true, + "esModuleInterop": true, + "moduleResolution": "node", + "outDir": "./dist", + "skipLibCheck": true }, - "include": ["src/**/*.ts"], + "include": ["src/**/*"], "exclude": ["node_modules"] -} +} \ No newline at end of file