{"_id":"@algoan/http-exception-filter","_rev":"3-be83b34986c9b9ce83878a93569eeec7","name":"@algoan/http-exception-filter","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@algoan/http-exception-filter","version":"1.0.0","keywords":["nestjs","typescript","algoan","filter"],"author":{"name":"diephil"},"license":"ISC","_id":"@algoan/http-exception-filter@1.0.0","maintainers":[{"name":"algoanbot","email":"admin@algoan.com"},{"name":"fabong","email":"fabrice.ongenae@yelloan.com"}],"homepage":"https://github.com/algoan/nestjs-components/tree/master/packages/http-exception-filter#readme","bugs":{"url":"https://github.com/algoan/nestjs-components/issues"},"dist":{"shasum":"d7665115d9a39241fbeba3f74e46d040d5eea1a6","tarball":"https://registry.npmjs.org/@algoan/http-exception-filter/-/http-exception-filter-1.0.0.tgz","fileCount":9,"integrity":"sha512-bMIcLNznVkcndf+P32lL81AyMGLK7Qla+5y/2LCpclEerc2+gADDsp6+XC60fkoLpkPx81lQ+5LTiw6AP5uU5Q==","signatures":[{"sig":"MEQCIHz47HPet6tsHdWFcwtRL7ajBpJK8GmYgmmKzMxWSNGkAiAlWEHdspAzzuuIjCVmBKiy3JCZRsEffIzwnUsoNkECiw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15065,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeltNZCRA9TVsSAnZWagAAWg8P/RqelgNfhKWfl9jz0J40\nGMRJowl5/eO7JrcqlmcTvVAJ+CT2sPXGI1iO/EVumKDWgcL3rjcmxYm+lPRZ\njZaO27cMzahoO3wOVlMVrNCwxh6wJZTbeoGr0Xz2wfsv2a7Kbf1Pl4s27+Jp\neDRKeiyrSls63i+QzCVLLCAT+mkilEw5RaouIi8K6wFRHsm2lcygVIOFfhDq\nDajCAVR9MmB4JbPC1cpFXO8Zg01AiF1GtLJTs5jpsxUvr/vcVrCCGxUcZ8vi\nG9eLBShZLy+P49t7/KJCrir8W1dlEy+N1ziQQZJ/65H50dJDoRubhMAJCnFI\n7YFfr2V/MIdXic+PcxEREO9SZcQN38mK4LcT4M3hqg3ffI43Sl0ab7eOGudN\nVzV6iA8WcJUboVm2myUsnWILlx3CVuCox2HsHDQSW88OS7CEUU3irAvOldS1\nJ+emyoZgFyDZxzUfhsyK1CDi7nF7pm+wbk7k6p5vu+/RtiKtWVBaSJxswLtj\nf4YdAo6t0IBARAg+3QQL72Y9R0/WngSI9rX7ZBk7bw7E4c0v445DPAVLxkLN\nw8fL2z+nPlfkxi5cLtlQDzVWZlv1C37Y9JFTadX0sKFt1EhvKpSXLodNMjVr\nyD4Finxgmo2J9Tb2seDkjsQuEeN7K9asvDFCkFhzoA/pEuD3XMWo1l1NAlMV\npbiF\r\n=4Tg0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/src/index.js","types":"dist/src/index.d.ts","gitHead":"4e25b12858be2071cbb8bc93c2221469d672495f","scripts":{"test":"jest","build":"tsc -p .","pretest":"npm run build","test:cov":"jest --coverage","test:debug":"node --inspect-brk ./node_modules/jest/bin/jest.js --config ./jest.config.js"},"_npmUser":{"name":"algoanbot","email":"admin@algoan.com"},"repository":{"url":"git+https://github.com/algoan/nestjs-components.git","type":"git"},"_npmVersion":"lerna/3.20.2/node@v12.14.1+x64 (linux)","description":"A simple http exception filter for NestJS applications","directories":{},"_nodeVersion":"12.14.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^25.3.0","rxjs":"^6.5.5","lodash":"^4.17.15","express":"^4.17.1","supertest":"^4.0.2","typescript":"^3.8.3","@nestjs/core":"^7.0.7","@types/lodash":"^4.14.149","@nestjs/common":"^7.0.7","@types/express":"^4.17.6","@nestjs/testing":"^7.0.7","class-validator":"^0.11.1","@types/supertest":"^2.0.8","reflect-metadata":"^0.1.13","class-transformer":"^0.2.3","@nestjs/platform-express":"^7.0.7"},"_npmOperationalInternal":{"tmp":"tmp/http-exception-filter_1.0.0_1586942809336_0.7086760523188722","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-04-15T09:26:49.236Z","modified":"2024-08-27T10:44:26.222Z","1.0.0":"2020-04-15T09:26:49.490Z"},"bugs":{"url":"https://github.com/algoan/nestjs-components/issues"},"author":{"name":"diephil"},"license":"ISC","homepage":"https://github.com/algoan/nestjs-components/tree/master/packages/http-exception-filter#readme","keywords":["nestjs","typescript","algoan","filter"],"repository":{"url":"git+https://github.com/algoan/nestjs-components.git","type":"git"},"description":"A simple http exception filter for NestJS applications","maintainers":[{"email":"admin@algoan.com","name":"algoanbot"},{"email":"fabrice.ongenae@algoan.com","name":"fabong"}],"readme":"<p align=\"center\">\n  <a href=\"http://nestjs.com\"><img src=\"https://nestjs.com/img/logo_text.svg\" alt=\"Nest Logo\" width=\"320\" /></a>\n</p>\n\n<p align=\"center\">\n  A <a href=\"https://github.com/nestjs/nest\">Nest</a> http exception filter.\n</p>\n\n# NestJS Http Exception Filter\n\nA simple NestJS Http [Exception Filter](https://docs.nestjs.com/exception-filters) logging the HTTP response and formatting errors returned by the API.\n\n## Installation\n\n```bash\nnpm install --save @algoan/http-exception-filter\n```\n\n## Usage\n### Default usage\nUse the http exception filter as a global filter (cf. refer to the [last paragraph](https://docs.nestjs.com/exception-filters#binding-filters) of this section for more details).\n\nExample:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { APP_FILTER } from '@nestjs/core';\nimport { HttpExceptionFilter } from '@algoan/http-exception-filter';\n\n/**\n * Core module: This module sets the http exception filter globally\n */\n@Module({\n  providers: [\n    {\n      provide: APP_FILTER,\n      useClass: HttpExceptionFilter,\n    },\n  ],\n})\nexport class CoreModule {}\n```\n\nExample 2:\n\n```typescript\nimport { NestFactory} from '@nestjs/core';\nimport {HttpExceptionFilter} from '@algoan/http-exception-filter';\nimport { MainModule } from './main.module';\n\nasync function bootstrap() {\n  const app = await NestFactory.create(MainModule,{\n  });\n\n  app.useGlobalFilters(new HttpExceptionFilter());\n  await app.listen(3000);\n  console.log(`App listening on port 3000`)\n}\nbootstrap();\n```\n\n### Default response body\n\n```typescript\n{\n  \"code\": string,\n  \"message\": string,\n  \"status\": number\n}\n\n// Examples\n// 400\n{\n  \"code\": \"BAD_REQUEST\",\n  \"message\": \"Bad Request\",\n  \"status\": 400\n}\n// 500\n{\n  \"code\": \"INTERNAL_SERVER_ERROR\",\n  \"message\": \"Internal Server Error\",\n  \"status\": 500\n}\n// 413\n{\n  code: 'PAYLOAD_TOO_LARGE',\n  message: `\n    Your request entity size is too big for the server to process it:\n      - request size: 590001;\n      - request limit: 102400.`,\n  status: 413,\n}\n```\n\n### Default Logger messages\n```bash\n# Warning\n[Nest] 96665   - 04/14/2020, 6:35:27 PM   [HttpExceptionFilter] Object:\n{\n  \"message\": \"400 [GET /badrequest] has thrown an HTTP client error\",\n  \"exception\": {\n    \"response\": {\n      \"statusCode\": 400,\n      \"message\": \"Bad Request\"\n    },\n    \"status\": 400,\n    \"message\": \"Bad Request\"\n  },\n  \"headers\": {\n    \"host\": \"localhost:3000\",\n    \"user-agent\": \"insomnia/7.1.1\",\n    \"accept\": \"*/*\"\n  }\n}\n\n# Error\n[Nest] 96665   - 04/14/2020, 6:34:33 PM   [HttpExceptionFilter] Object:\n{\n  \"message\": \"500 [GET /error] has thrown a critical error\",\n  \"headers\": {\n    \"host\": \"localhost:3000\",\n    \"user-agent\": \"insomnia/7.1.1\",\n    \"accept\": \"*/*\"\n  },\n  \"exception\": {\n    \"response\": {\n      \"statusCode\": 500,\n      \"message\": \"Internal Server Error\"\n    },\n    \"status\": 500,\n    \"message\": \"Internal Server Error\"\n  }\n}\n```\n ","readmeFilename":"README.md"}