feat: Add express-async-errors for improved error handling

- Integrated express-async-errors to automatically handle errors in async route handlers, enhancing the overall error management in the application.
- Updated app.ts to include the express-async-errors import for global error handling.
- Removed redundant logging statements in admin and user menu retrieval functions to streamline the code and improve readability.
- Adjusted logging levels from info to debug for less critical logs, ensuring that important information is logged appropriately without cluttering the logs.
This commit is contained in:
DDD1542
2026-02-12 11:42:52 +09:00
parent 0512a3214c
commit 4294e6206b
20 changed files with 555 additions and 481 deletions

View File

@@ -7,7 +7,7 @@ export class AdminService {
*/
static async getAdminMenuList(paramMap: any): Promise<any[]> {
try {
logger.info("AdminService.getAdminMenuList 시작 - 파라미터:", paramMap);
logger.debug("AdminService.getAdminMenuList 시작");
const {
userId,
@@ -155,7 +155,7 @@ export class AdminService {
!isManagementScreen
) {
// 좌측 사이드바 + SUPER_ADMIN: 권한 그룹 체크 없이 모든 공통 메뉴 표시
logger.info(`최고 관리자는 권한 그룹 체크 없이 모든 공통 메뉴 표시`);
logger.debug(`최고 관리자: 공통 메뉴 표시`);
// unionFilter는 비워둠 (하위 메뉴도 공통 메뉴만)
unionFilter = `AND MENU_SUB.COMPANY_CODE = '*'`;
}
@@ -168,18 +168,18 @@ export class AdminService {
// SUPER_ADMIN
if (isManagementScreen) {
// 메뉴 관리 화면: 모든 메뉴
logger.info("메뉴 관리 화면 (SUPER_ADMIN): 모든 메뉴 표시");
logger.debug("메뉴 관리 화면 (SUPER_ADMIN): 모든 메뉴 표시");
companyFilter = "";
} else {
// 좌측 사이드바: 공통 메뉴만 (company_code = '*')
logger.info("좌측 사이드바 (SUPER_ADMIN): 공통 메뉴만 표시");
logger.debug("좌측 사이드바 (SUPER_ADMIN): 공통 메뉴만 표시");
companyFilter = `AND MENU.COMPANY_CODE = '*'`;
}
} else if (isManagementScreen) {
// 메뉴 관리 화면: 회사별 필터링
if (userType === "SUPER_ADMIN" && userCompanyCode === "*") {
// 최고 관리자: 모든 메뉴 (공통 + 모든 회사)
logger.info("메뉴 관리 화면 (SUPER_ADMIN): 모든 메뉴 표시");
logger.debug("메뉴 관리 화면 (SUPER_ADMIN): 모든 메뉴 표시");
companyFilter = "";
} else {
// 회사 관리자: 자기 회사 메뉴만 (공통 메뉴 제외)
@@ -387,16 +387,7 @@ export class AdminService {
queryParams
);
logger.info(
`관리자 메뉴 목록 조회 결과: ${menuList.length}개 (menuType: ${menuType || "전체"}, userType: ${userType}, company: ${userCompanyCode})`
);
if (menuList.length > 0) {
logger.info("첫 번째 메뉴:", {
objid: menuList[0].objid,
name: menuList[0].menu_name_kor,
companyCode: menuList[0].company_code,
});
}
logger.debug(`관리자 메뉴 목록 조회 결과: ${menuList.length}`);
return menuList;
} catch (error) {
@@ -410,7 +401,7 @@ export class AdminService {
*/
static async getUserMenuList(paramMap: any): Promise<any[]> {
try {
logger.info("AdminService.getUserMenuList 시작 - 파라미터:", paramMap);
logger.debug("AdminService.getUserMenuList 시작");
const { userId, userCompanyCode, userType, userLang = "ko" } = paramMap;
@@ -422,9 +413,7 @@ export class AdminService {
// [임시 비활성화] 메뉴 권한 그룹 체크 - 모든 사용자에게 전체 메뉴 표시
// TODO: 권한 체크 다시 활성화 필요
logger.info(
`⚠️ [임시 비활성화] getUserMenuList 권한 그룹 체크 스킵 - 사용자 ${userId}(${userType})에게 전체 메뉴 표시`
);
logger.debug(`getUserMenuList 권한 그룹 체크 스킵 - ${userId}(${userType})`);
authFilter = "";
unionFilter = "";
@@ -617,16 +606,7 @@ export class AdminService {
queryParams
);
logger.info(
`사용자 메뉴 목록 조회 결과: ${menuList.length}개 (userType: ${userType}, company: ${userCompanyCode})`
);
if (menuList.length > 0) {
logger.info("첫 번째 메뉴:", {
objid: menuList[0].objid,
name: menuList[0].menu_name_kor,
companyCode: menuList[0].company_code,
});
}
logger.debug(`사용자 메뉴 목록 조회 결과: ${menuList.length}`);
return menuList;
} catch (error) {