You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nestjs is famous among nodejs API framework, it would be helpful to have a short section describe how to use this with nestjs.
I tried to copy the code provided in readme but it does not work, I think other people might have the same experience.
FYI, this is what i have done:
Follow Nestjs guide to create a new nestjs app.
Follow readme.md in this repo to create all necessary files
Throw an error in app.controller.ts: throw new NotFoundError({type: 'customer', id: '123' })
add HttpProblemResponse to main.ts:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { HttpProblemResponse } from 'express-http-problem-details';
import { NotFoundErrorMapper } from './ErrorMapper';
import { DefaultMappingStrategy, MapperRegistry } from 'http-problem-details-mapper'
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const strategy = new DefaultMappingStrategy(
new MapperRegistry()
.registerMapper(new NotFoundErrorMapper()))
app.use(HttpProblemResponse({ strategy }))
await app.listen(3000);
}
bootstrap();
Expected result:
{
"status": 404,
"title": "customer with id 123 could not be found.",
"type": "http://tempuri.org/NotFoundError"
}
Actual Result:
{
"statusCode": 500,
"message": "Internal server error"
}
The text was updated successfully, but these errors were encountered:
Nestjs is famous among nodejs API framework, it would be helpful to have a short section describe how to use this with nestjs.
I tried to copy the code provided in readme but it does not work, I think other people might have the same experience.
FYI, this is what i have done:
Follow Nestjs guide to create a new nestjs app.
Follow readme.md in this repo to create all necessary files
Throw an error in app.controller.ts:
throw new NotFoundError({type: 'customer', id: '123' })
add HttpProblemResponse to main.ts:
Expected result:
Actual Result:
The text was updated successfully, but these errors were encountered: