diff --git a/.circleci/config.yml b/.circleci/config.yml index 373e807..b5b6e39 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,6 +34,4 @@ jobs: - node_modules key: v1-dependencies-{{ checksum "yarn.lock" }} - # run tests! - - run: yarn test diff --git a/README.md b/README.md index c98ad2f..ad466d0 100644 --- a/README.md +++ b/README.md @@ -67,10 +67,10 @@ Notice that the `HttpProblemResponse` must come last. A global error logger woul precede it and forward the error to the `next` function. ```js -import { ExpressMappingStrategy, HttpProblemResponse } from 'express-http-problem-details' -import { MapperRegistry } from 'http-problem-details-mapper' +import { HttpProblemResponse } from 'express-http-problem-details' +import { DefaultMappingStrategy, MapperRegistry } from 'http-problem-details-mapper' -const strategy = new ExpressMappingStrategy( +const strategy = new DefaultMappingStrategy( new MapperRegistry() .registerMapper(new NotFoundErrorMapper())) diff --git a/package.json b/package.json index b3f14f5..2fc9360 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ }, "dependencies": { "http-problem-details": "^0.1.2", - "http-problem-details-mapper": "^0.1.3" + "http-problem-details-mapper": "^0.1.4" }, "husky": { "hooks": { diff --git a/src/ExpressMappingStrategy.ts b/src/ExpressMappingStrategy.ts deleted file mode 100644 index 844b0f0..0000000 --- a/src/ExpressMappingStrategy.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { IMappingStrategy, MapperRegistry } from 'http-problem-details-mapper' -import { ProblemDocument } from 'http-problem-details' - -export class ExpressMappingStrategy implements IMappingStrategy { - public registry: MapperRegistry; - - public constructor (registry: MapperRegistry) { - this.registry = registry - } - - public map (error: any): ProblemDocument | null { - const err = error - const errorMapper = this.registry.getMapper(error) - if (errorMapper) { - return errorMapper.mapError(err) - } - - return null - } -} diff --git a/src/index.ts b/src/index.ts index d546913..3922c83 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,5 @@ -import { ExpressMappingStrategy } from './ExpressMappingStrategy' import { HttpProblemResponse } from './HttpProblemResponse' export { - ExpressMappingStrategy, HttpProblemResponse } diff --git a/test/ExpressMappingStrategyTests.ts b/test/ExpressMappingStrategyTests.ts deleted file mode 100644 index 694d067..0000000 --- a/test/ExpressMappingStrategyTests.ts +++ /dev/null @@ -1,15 +0,0 @@ -import 'should' -import { ExpressMappingStrategy } from '../src' -import { MapperRegistry } from 'http-problem-details-mapper' - -describe('ExpressMappingStrategy', (): void => { - describe('When mapping', (): void => { - it('should return status code 500 problem', function (done): void { - const strategy = new ExpressMappingStrategy(new MapperRegistry()) - const problem = strategy.map(new Error())! - problem.should.have.property('type', 'about:blank') - problem.status.should.equal(500) - return done() - }) - }) -}) diff --git a/yarn.lock b/yarn.lock index ca1a3fc..dbfe429 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1416,10 +1416,10 @@ hosted-git-info@^2.1.4: resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047" integrity sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w== -http-problem-details-mapper@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/http-problem-details-mapper/-/http-problem-details-mapper-0.1.3.tgz#4901e550d3081fb713b67157300b83ad41dc230d" - integrity sha512-Ps/DNwhH4cM6Sneh5Qg7ud+lTAsMmQuFDdMAKWwd7lx6pGPNh8A3c9T9O2BktN2J4mXk41zfTpMe1bMiItUviQ== +http-problem-details-mapper@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/http-problem-details-mapper/-/http-problem-details-mapper-0.1.4.tgz#c231858e3e3a1e9521a2750b82114e83cbe61ae9" + integrity sha512-gvNuKvQzJvAoN6QklhgZD70YpuQujNA+9zLUKV7Kj8ha04HMfp9TbBVyw3GA8kc9xaNcwx6/BTZevKTemzGikQ== http-problem-details@^0.1.2: version "0.1.4"