Add initial Nuxt 4 project setup with essential configurations

- Created .gitignore to exclude build outputs, logs, and environment files.
- Added nuxt.config.ts for project configuration, enabling Tailwind CSS and Pinia modules.
- Initialized package.json with scripts for development and production, and added necessary dependencies.
- Generated pnpm-lock.yaml for dependency management.
- Created README.md with setup instructions and development guidelines.
- Implemented server API examples in server/api/ directory, demonstrating various use cases.
- Added middleware for logging requests and responses.
- Included example Vue components and pages for server API interaction.
- Established basic project structure for Nuxt 4 application development.
This commit is contained in:
hyeonggil
2026-04-08 23:59:29 +09:00
commit fc7d3d14cf
27 changed files with 9954 additions and 0 deletions

31
server/utils/response.ts Normal file
View File

@@ -0,0 +1,31 @@
/**
* 서버 유틸: 공통 응답 형식 헬퍼
*
* - server/utils/ 하위 파일은 서버 전체에서 auto-import
* - import 없이 바로 사용 가능: apiSuccess(), apiError() 등
* - 클라이언트 코드에는 노출되지 않음 (서버 전용)
*/
export interface ApiResponse<T> {
success: boolean;
data: T | null;
error: string | null;
meta?: Record<string, unknown>;
}
/** 성공 응답 래퍼 */
export function apiSuccess<T>(data: T, meta?: Record<string, unknown>): ApiResponse<T> {
return { success: true, data, error: null, meta };
}
/** 실패 응답 래퍼 (에러를 던지지 않고 응답으로 처리할 때) */
export function apiFailure(message: string): ApiResponse<null> {
return { success: false, data: null, error: message };
}
/** Authorization 헤더에서 Bearer 토큰 추출 */
export function extractBearerToken(event: Parameters<typeof getHeader>[0]): string | null {
const auth = getHeader(event, "authorization");
if (!auth?.startsWith("Bearer ")) return null;
return auth.slice(7);
}