From 2d887163825527965e14eb8b762d5d43cd9fb384 Mon Sep 17 00:00:00 2001 From: Alexander Zeitler Date: Thu, 14 Nov 2019 21:35:19 +0100 Subject: [PATCH] docs: add DefaultMappingStrategy --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 235c114..fade5d1 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,23 @@ import { StatusCodeErrorMapper } from 'http-problem-details-mapper' const problem = StatusCodeErrorMapper.mapStatusCode(400) ``` +Similar to the `DefaultErrorMapper` there's also a `DefaultMappingStrategy` which you can use if you have no specific requirements regarding the mapping behavior. + +It can be used like this: + +```js +import { MapperRegistry, DefaultMappingStrategy } from 'http-problem-details-mapper' + +const strategy = new DefaultMappingStrategy( + new MapperRegistry() + .registerMapper(new NotFoundErrorMapper())) + +const error = new NotFoundError({ type: 'customer', id: '123' }) +const problem = strategy.map() + +console.log(problem) +``` + ## Running the tests ```