Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
주요 기능 설명
1. 회원가입 (
/auth/signup)username,password,region정보를 제공하여 회원가입을 진행합니다.users테이블에 저장하며, MySQL의INSERT쿼리를 통해 사용자 데이터를 저장합니다.2. 로그인 (
/auth/login)username과password를 입력하여 로그인합니다.3. 로그아웃 (
/auth/logout)4. 사용자 정보 조회 (
/users)GET /users/me: 쿠키에서 가져온 사용자 ID로 현재 로그인된 사용자의 정보를 반환합니다.GET /users/:userId: 특정 사용자 ID를 기반으로 정보를 조회합니다.5. 후보 등록 (
/candidates)candidates테이블에 사용자의 ID를 저장하여 후보 등록 정보를 관리합니다.6. 지역별 후보 조회 (
/candidates/:region)users테이블과candidates테이블을 조인하여 후보의 이름과 ID를 반환합니다.주요 코드 구조와 설명
1. 폴더 구조
2. 라우트 구조
authRoutes.js: 인증 기능 처리candidateRoutes.js: 후보 등록 및 조회 처리userRoutes.js: 사용자 정보 조회 처리3. 데이터베이스 연결
db.js파일에서 MySQL 데이터베이스 연결을mysql2/promise라이브러리를 사용해 비동기로 처리합니다..env파일에서 DB 정보를 관리하여 보안성을 유지합니다.