
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
@algoan/nestjs-http-exception-filter
Advanced tools
A simple http exception filter for NestJS applications
A Nest http exception filter.
A simple NestJS Http Exception Filter logging the HTTP response and formatting errors returned by the API.
npm install --save @algoan/nestjs-http-exception-filter
Use the http exception filter as a global filter (cf. refer to the last paragraph of this section for more details).
Example:
import { Module } from '@nestjs/common';
import { APP_FILTER } from '@nestjs/core';
import { HttpExceptionFilter } from '@algoan/nestjs-http-exception-filter';
/**
* Core module: This module sets the http exception filter globally
*/
@Module({
providers: [
{
provide: APP_FILTER,
useClass: HttpExceptionFilter,
},
],
})
export class CoreModule {}
Example 2:
import { NestFactory} from '@nestjs/core';
import {HttpExceptionFilter} from '@algoan/nestjs-http-exception-filter';
import { MainModule } from './main.module';
async function bootstrap() {
const app = await NestFactory.create(MainModule,{
});
app.useGlobalFilters(new HttpExceptionFilter());
await app.listen(3000);
console.log(`App listening on port 3000`)
}
bootstrap();
{
"code": string,
"message": string,
"status": number
}
// Examples
// 400
{
"code": "BAD_REQUEST",
"message": "Bad Request",
"status": 400
}
// 500
{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal Server Error",
"status": 500
}
// 413
{
code: 'PAYLOAD_TOO_LARGE',
message: `
Your request entity size is too big for the server to process it:
- request size: 590001;
- request limit: 102400.`,
status: 413,
}
# Warning
[Nest] 96665 - 04/14/2020, 6:35:27 PM [HttpExceptionFilter] Object:
{
"message": "400 [GET /badrequest] has thrown an HTTP client error",
"exceptionStack": "stackTrace",
"headers": {
"host": "localhost:3000",
"user-agent": "insomnia/7.1.1",
"accept": "*/*"
}
}
# Error
[Nest] 96665 - 04/14/2020, 6:34:33 PM [HttpExceptionFilter] Object:
{
"message": "500 [GET /error] has thrown a critical error",
"headers": {
"host": "localhost:3000",
"user-agent": "insomnia/7.1.1",
"accept": "*/*"
},
"exceptionStack": "stackTrace",
}
FAQs
A simple http exception filter for NestJS applications
The npm package @algoan/nestjs-http-exception-filter receives a total of 910 weekly downloads. As such, @algoan/nestjs-http-exception-filter popularity was classified as not popular.
We found that @algoan/nestjs-http-exception-filter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.