{"_id":"@3xhaust/nest-response","_rev":"2-c696576d14c2ed9fc06254a88a72843a","name":"@3xhaust/nest-response","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@3xhaust/nest-response","version":"1.0.0","keywords":["nestjs","response","interceptor","exception-filter","api"],"license":"MIT","_id":"@3xhaust/nest-response@1.0.0","maintainers":[{"name":"3xhaust","email":"s2424@e-mirim.hs.kr"}],"dist":{"shasum":"113596fd585b410ab5c29f34b3ea39174983427b","tarball":"https://registry.npmjs.org/@3xhaust/nest-response/-/nest-response-1.0.0.tgz","fileCount":27,"integrity":"sha512-KlrszX+2ybsj19KGf7vimNeETuT4SvHegMxpqTbACA+F4/gzE7lA39CeOL2OIvCNcvri37K+K8HFxU0+SPk/sQ==","signatures":[{"sig":"MEQCIGwILSJonvHASN0660x6BOKSzO4xGKaxbv5tNzDy6yYBAiAm464QvLfgppbP7ZEULmDnFENf/3kYsxEUNH7O/8WI1g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23499},"main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"0f3b5697488aba2893701a9bae4d9f174ed4c0cc","scripts":{"test":"jest --runInBand","build":"npm run clean && tsc -p tsconfig.build.json","clean":"rm -rf dist coverage","test:watch":"jest --watch","prepublishOnly":"npm run build && npm test"},"_npmUser":{"name":"3xhaust","email":"s2424@e-mirim.hs.kr"},"_npmVersion":"10.8.2","description":"Opinionated NestJS response standardization library","directories":{},"sideEffects":false,"_nodeVersion":"20.19.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rxjs":"^7.8.1","ts-jest":"^29.2.5","typescript":"^5.7.2","@types/jest":"^29.5.14","@types/node":"^20.17.6","@nestjs/core":"^10.4.15","@nestjs/common":"^10.4.15","reflect-metadata":"^0.2.2"},"peerDependencies":{"rxjs":"^7.8.0","@nestjs/core":"^10.0.0 || ^11.0.0","@nestjs/common":"^10.0.0 || ^11.0.0","reflect-metadata":"^0.1.13 || ^0.2.0"},"_npmOperationalInternal":{"tmp":"tmp/nest-response_1.0.0_1773375478281_0.25827189182891575","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@3xhaust/nest-response","version":"1.1.0","description":"Opinionated NestJS response standardization library","license":"MIT","keywords":["nestjs","response","interceptor","exception-filter","api"],"main":"dist/index.js","types":"dist/index.d.ts","sideEffects":false,"publishConfig":{"access":"public"},"exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.js","default":"./dist/index.js"}},"scripts":{"clean":"rm -rf dist coverage","build":"npm run clean && tsc -p tsconfig.build.json","test":"jest --runInBand","test:watch":"jest --watch","prepublishOnly":"npm run build && npm test"},"peerDependencies":{"@nestjs/common":"^10.0.0 || ^11.0.0","@nestjs/core":"^10.0.0 || ^11.0.0","reflect-metadata":"^0.1.13 || ^0.2.0","rxjs":"^7.8.0"},"devDependencies":{"@nestjs/common":"^10.4.15","@nestjs/core":"^10.4.15","@types/jest":"^29.5.14","@types/node":"^20.17.6","jest":"^29.7.0","reflect-metadata":"^0.2.2","rxjs":"^7.8.1","ts-jest":"^29.2.5","typescript":"^5.7.2"},"_id":"@3xhaust/nest-response@1.1.0","gitHead":"175ff9d96eff37835ce06feba6799969c637181e","_nodeVersion":"20.19.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-EupEiDCYfhBMJ2AxQ6YQnSGV8u9cEaVKwN4VxU3W+XWay/i1bdCRUqpkM5LwQH1wNjJDp/pFIW24JpGgYKqVpg==","shasum":"06bb1fccf5bd318c43a4c705a03bbc5a56bcff42","tarball":"https://registry.npmjs.org/@3xhaust/nest-response/-/nest-response-1.1.0.tgz","fileCount":27,"unpackedSize":27653,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDPFV3Sz1brGrP5Su+rPfZpWBG+SwkzoDiIR/qLdecdrQIhAIdFbHGtKdQmEwtGgLLB1eiNziPShcRNCOzJrNXPAn5Y"}]},"_npmUser":{"name":"3xhaust","email":"s2424@e-mirim.hs.kr"},"directories":{},"maintainers":[{"name":"3xhaust","email":"s2424@e-mirim.hs.kr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nest-response_1.1.0_1773994900275_0.4829477237210542"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-13T04:17:58.171Z","modified":"2026-03-20T08:21:40.542Z","1.0.0":"2026-03-13T04:17:58.436Z","1.1.0":"2026-03-20T08:21:40.427Z"},"license":"MIT","keywords":["nestjs","response","interceptor","exception-filter","api"],"description":"Opinionated NestJS response standardization library","maintainers":[{"name":"3xhaust","email":"s2424@e-mirim.hs.kr"}],"readme":"# @3xhaust/nest-response\n\nNestJS 전용 응답 표준화 라이브러리입니다.\n\n성공 응답과 예외 응답을 모두 아래와 동일한 외부 구조로 통일합니다.\n\n```ts\n{\n  statusCode: number;\n  data: T | null;\n  message: string[];\n  timestamp: string;\n}\n```\n\n## 설계 규칙\n\n- NestJS 전용\n- `message`는 항상 `string[]`\n- `timestamp`는 항상 ISO 문자열\n- 성공/에러 응답은 동일한 외부 구조 사용\n- `data ?? null` 규칙 사용 (`0`, `false`, `\"\"` 유지)\n- 이미 최종 응답 형태면 다시 래핑하지 않음\n- 기본 성공 메시지: `[\"Success\"]`\n- 알 수 없는 에러 기본 메시지: `[\"Internal server error\"]`\n\n## 설치\n\n```bash\nnpm install @3xhaust/nest-response\n```\n\n## 빠른 시작\n\n```ts\nimport { NestFactory } from '@nestjs/core';\nimport { AppModule } from './app.module';\nimport { applyNestResponse } from '@3xhaust/nest-response';\n\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule);\n  applyNestResponse(app);\n  await app.listen(3000);\n}\n\nbootstrap();\n```\n\n에러 디버깅이 필요하면 옵션으로 로그/메시지 노출 정책을 설정할 수 있습니다.\n\n```ts\napplyNestResponse(app, {\n  allExceptionsFilter: {\n    logUnknownErrors: true,\n    exposeUnknownErrorMessages: process.env.NODE_ENV !== 'production',\n  },\n});\n```\n\n## 컨트롤러 예제\n\n```ts\nimport { Controller, Get } from '@nestjs/common';\nimport { SuccessMessage } from '@3xhaust/nest-response';\n\n@Controller('users')\nexport class UsersController {\n  @Get()\n  @SuccessMessage('Users fetched')\n  findAll() {\n    return [{ id: 1, name: 'lyu' }];\n  }\n}\n```\n\n응답 예시:\n\n```json\n{\n  \"statusCode\": 200,\n  \"data\": [{ \"id\": 1, \"name\": \"lyu\" }],\n  \"message\": [\"Users fetched\"],\n  \"timestamp\": \"2026-03-13T11:11:11.000Z\"\n}\n```\n\n## 전체 실행 예제\n\n실행 가능한 샘플 앱은 `examples/basic`에 있습니다.\n\n```bash\ncd examples/basic\nnpm install\nnpm run start\n```\n\n## API\n\n### `ApiResponse<T>`\n\n```ts\ninterface ApiResponse<T> {\n  statusCode: number;\n  data: T | null;\n  message: string[];\n  timestamp: string;\n}\n```\n\n### `SuccessMessage(...messages: string[])`\n\n성공 응답의 `message`를 지정하는 데코레이터입니다.\n\n- 메서드 또는 컨트롤러 클래스에 적용 가능\n- 설정 시 해당 메시지를 사용\n- 미설정 시 기본값 `['Success']` 사용\n\n### `TransformInterceptor`\n\n일반 성공 반환값을 표준 응답 형태로 변환합니다.\n\n동작:\n\n- 비표준 payload를 `{ statusCode, data: payload ?? null, message, timestamp }`로 래핑\n- `@SuccessMessage(...)` 메타데이터가 있으면 사용\n- 없으면 기본 성공 메시지 사용\n- 이미 `ApiResponse` 형태면 재래핑하지 않음 (`timestamp` 누락 시 보강)\n\n### `AllExceptionsFilter`\n\n발생한 예외를 표준 응답 형태로 정규화합니다.\n\n동작:\n\n- 문자열 메시지 예외 -> `string[]`로 변환\n- 배열 메시지 예외 -> 그대로 유지\n- 알 수 없는 에러 -> `500`, `data: null`, `message: [\"Internal server error\"]`\n- 모든 에러 응답에 `timestamp` 포함\n- 이미 표준 형태 예외 응답은 보존 (`timestamp` 없으면 자동 추가)\n\n### `applyNestResponse(app)`\n\n전역으로 아래를 등록합니다.\n\n- `TransformInterceptor`\n- `AllExceptionsFilter`\n\n시그니처:\n\n```ts\napplyNestResponse(app, {\n  allExceptionsFilter?: {\n    logUnknownErrors?: boolean; // default: true\n    exposeUnknownErrorMessages?: boolean; // default: false\n  };\n});\n```\n\n- `logUnknownErrors`: 미분류 예외 및 5xx 예외를 서버 로그로 출력\n- `exposeUnknownErrorMessages`: 미분류 예외의 원본 `Error.message`를 응답 메시지로 노출\n","readmeFilename":"README.md"}