ERP-node/backend-node
DDD1542 d43f0821ed refactor: Update authentication handling in authRoutes and useAuth hook
- Replaced the middleware `checkAuthStatus` with the `AuthController.checkAuthStatus` method in the authentication routes for improved clarity and structure.
- Simplified token validation logic in the `useAuth` hook by removing unnecessary checks for expired tokens, allowing the API client to handle token refresh automatically.
- Enhanced logging for authentication checks to provide clearer insights into the authentication flow and potential issues.
- Adjusted the handling of user authentication status to ensure consistency and reliability in user state management.

This refactor streamlines the authentication process and improves the overall maintainability of the authentication logic.
2026-03-05 11:51:05 +09:00
..
data 메일관련된거 커밋 2025-11-28 11:34:48 +09:00
scripts feat: Digital Twin Editor 테이블 매핑 UI 및 백엔드 API 구현 2025-11-20 10:15:58 +09:00
src refactor: Update authentication handling in authRoutes and useAuth hook 2026-03-05 11:51:05 +09:00
uploads 테이블 리스트 기능 수정 2025-09-15 11:43:59 +09:00
.env.example 자잘한 오류 수정과 스크롤, 헤더 변경완료 2025-10-17 14:52:08 +09:00
.env.shared 배송/화물현황과 리스크/알림(api 활용, 공공데이터 복구시 대체될 가능성 있음) 2025-10-14 16:36:00 +09:00
API_연동_가이드.md 배송/화물현황과 리스크/알림(api 활용, 공공데이터 복구시 대체될 가능성 있음) 2025-10-14 16:36:00 +09:00
API_키_정리.md 배송/화물현황과 리스크/알림(api 활용, 공공데이터 복구시 대체될 가능성 있음) 2025-10-14 16:36:00 +09:00
Dockerfile.win docs: 모든 문서에서 Prisma 참조 제거 및 Raw Query로 업데이트 2025-10-01 15:03:08 +09:00
PHASE1_USAGE_GUIDE.md feat: Complete Phase 1 of Prisma to Raw Query migration 2025-09-30 15:29:20 +09:00
README.md feat(pop-card-list): PopCardList 컴포넌트 구현 2026-02-24 15:54:57 +09:00
README_API_SETUP.md 배송/화물현황과 리스크/알림(api 활용, 공공데이터 복구시 대체될 가능성 있음) 2025-10-14 16:36:00 +09:00
install-multer.js 파일 컴포넌트 분리 2025-09-05 21:52:19 +09:00
jest.config.js chore: Remove obsolete .classpath file 2026-03-04 15:31:45 +09:00
nodemon.json 각 회사별 데이터 분리 2025-10-27 16:40:59 +09:00
package-lock.json feat: Enhance SplitPanelLayout with modal support for add and edit buttons 2026-02-12 14:54:14 +09:00
package.json feat: Add express-async-errors for improved error handling 2026-02-12 11:42:52 +09:00
performance-test.js 라벨명 표시기능 2025-09-08 14:20:01 +09:00
tsconfig.json 각 회사별 데이터 분리 2025-10-27 16:40:59 +09:00

README.md

re# PLM System Backend - Node.js + TypeScript

Java Spring Boot에서 Node.js + TypeScript로 리팩토링된 PLM 시스템 백엔드입니다.

🚀 기술 스택

  • Runtime: Node.js ^20.10.0
  • Framework: Express ^4.18.2
  • Language: TypeScript ^5.3.3
  • Database: PostgreSQL ^8.11.3 (Raw Query with pg)
  • Authentication: JWT + Passport
  • Testing: Jest + Supertest

📋 프로젝트 구조

backend-node/
├── src/
│   ├── database/        # 데이터베이스 유틸리티
│   │   ├── db.ts        # PostgreSQL Raw Query 헬퍼
│   │   └── ...
│   ├── controllers/     # HTTP 요청 처리
│   ├── services/        # 비즈니스 로직
│   ├── middleware/      # Express 미들웨어
│   │   └── errorHandler.ts
│   ├── utils/           # 유틸리티 함수
│   │   └── logger.ts
│   ├── types/           # TypeScript 타입 정의
│   │   └── common.ts
│   ├── validators/      # 입력 검증 스키마
│   └── app.ts          # 애플리케이션 진입점
├── logs/               # 로그 파일
├── package.json
├── tsconfig.json
└── README.md

🛠️ 설치 및 실행

1. 의존성 설치

npm install

2. 환경 변수 설정

.env 파일을 생성하고 다음 내용을 추가하세요:

DATABASE_URL="postgresql://postgres:ph0909!!@39.117.244.52:11132/plm"
JWT_SECRET="your-super-secret-jwt-key-change-in-production"
JWT_EXPIRES_IN="24h"
PORT=8080
NODE_ENV=development

3. 개발 서버 실행

npm run dev

5. 프로덕션 빌드

npm run build
npm start

📊 데이터베이스 스키마

PostgreSQL 데이터베이스를 직접 Raw Query로 사용합니다.

핵심 테이블

  • user_info - 사용자 정보
  • dept_info - 부서 정보
  • menu_info - 메뉴 정보
  • comm_code - 공통 코드
  • multi_lang_key_master - 다국어 키 마스터
  • multi_lang_text - 다국어 텍스트

자세한 스키마 정보는 docs/Database_Schema_Collection.md를 참조하세요.

🔐 인증 시스템

JWT 기반 인증 시스템을 구현했습니다:

  • Access Token (24시간)
  • Refresh Token (7일)
  • 토큰 자동 갱신

📝 API 문서

헬스 체크

GET http://localhost:8080/health

사용자 관리 (예정)

GET    http://localhost:8080/api/users              # 사용자 목록 조회
GET    http://localhost:8080/api/users/:id          # 특정 사용자 조회
POST   http://localhost:8080/api/users              # 사용자 생성
PUT    http://localhost:8080/api/users/:id          # 사용자 수정
DELETE http://localhost:8080/api/users/:id          # 사용자 삭제

메뉴 관리 (예정)

GET    http://localhost:8080/api/menus              # 메뉴 목록 조회
POST   http://localhost:8080/api/menus              # 메뉴 생성
PUT    http://localhost:8080/api/menus/:id          # 메뉴 수정
DELETE http://localhost:8080/api/menus/:id          # 메뉴 삭제

🧪 테스트

# 전체 테스트 실행
npm test

# 테스트 감시 모드
npm run test:watch

📦 스크립트

  • npm run dev - 개발 서버 실행 (nodemon)
  • npm run build - TypeScript 컴파일
  • npm start - 프로덕션 서버 실행
  • npm test - 테스트 실행
  • npm run lint - ESLint 검사
  • npm run format - Prettier 포맷팅

🔧 개발 가이드

새로운 API 추가

  1. src/controllers/에 컨트롤러 생성
  2. src/services/에 서비스 로직 생성
  3. src/types/에 타입 정의 추가
  4. src/validators/에 검증 스키마 추가
  5. src/app.ts에 라우터 등록

데이터베이스 스키마 변경

  1. SQL 마이그레이션 파일 작성 (db/ 디렉토리)
  2. PostgreSQL에서 직접 실행
  3. 필요 시 TypeScript 타입 정의 업데이트 (src/types/)

📋 마이그레이션 체크리스트

Phase 1: 기반 구축 (완료)

  • Node.js + TypeScript 프로젝트 설정
  • 기존 데이터베이스 스키마 분석
  • PostgreSQL Raw Query 시스템 구축
  • 기본 인증 시스템 구현
  • 에러 처리 및 로깅 설정

🔄 Phase 2: 핵심 API 개발 (진행 중)

  • 사용자 관리 API (user_info 테이블 기반)
  • 부서 관리 API (dept_info 테이블 기반)
  • 메뉴 관리 API (menu_info 테이블 기반)
  • 권한 관리 API (authority_master, rel_menu_auth 테이블 기반)
  • 다국어 관리 API (multi_lang_key_master, multi_lang_text 테이블 기반)
  • 공통 코드 관리 API (comm_code 테이블 기반)

Phase 3: 비즈니스 로직 API (예정)

  • 회사 관리 API (company_mng 테이블 기반)
  • 계약 관리 API (contract_mgmt 테이블 기반)
  • 주문 관리 API (order_mgmt 테이블 기반)
  • 재고 관리 API (inventory_mgmt 테이블 기반)
  • 부품 관리 API (part_mgmt 테이블 기반)

🚀 배포

Docker 배포

# Docker 이미지 빌드
docker build -t pms-backend-node .

# 컨테이너 실행
docker run -p 8080:8080 pms-backend-node

환경별 설정

  • Development: NODE_ENV=development
  • Production: NODE_ENV=production
  • Test: NODE_ENV=test

📞 지원

프로젝트 관련 문의사항이 있으시면 개발팀에 연락해주세요.


버전: 1.0.0
마지막 업데이트: 2024년 12월