Skip to content

Commit

Permalink
fix: Login/Register 기능 수행 완료:
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-Dongwook committed Oct 20, 2024
1 parent d86a3cd commit 7d0af38
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
9 changes: 7 additions & 2 deletions client/src/template/RegisterPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
"use client";

import { useState } from "react";
Expand All @@ -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);
}
};

Expand Down
1 change: 0 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"type":"module",
"scripts": {
"dev": "nodemon src/server.ts",
"test": "jest",
Expand Down
5 changes: 5 additions & 0 deletions server/src/routes/authRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ router.post("/register", async (req: Request, res: Response): Promise<void> => {

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" });
}
});
Expand Down
17 changes: 9 additions & 8 deletions server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}

0 comments on commit 7d0af38

Please sign in to comment.