Skip to content

Commit

Permalink
feat: upgrade packages, fix imports, fix return types, fix empty try-…
Browse files Browse the repository at this point in the history
…catch
  • Loading branch information
lennartquerter committed Dec 10, 2022
1 parent bf45577 commit 486dcbe
Show file tree
Hide file tree
Showing 7 changed files with 1,016 additions and 1,036 deletions.
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,40 @@
"README.md"
],
"devDependencies": {
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@nestjs/common": "^9.1.4",
"@nestjs/core": "^9.1.4",
"@nestjs/testing": "^9.1.4",
"@pact-foundation/pact": "^10.1.4",
"@semantic-release/changelog": "^6.0.1",
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"@nestjs/common": "^9.2.1",
"@nestjs/core": "^9.2.1",
"@nestjs/testing": "^9.2.1",
"@pact-foundation/pact": "^10.4.0",
"@semantic-release/changelog": "^6.0.2",
"@semantic-release/git": "^10.0.1",
"@types/get-port": "^4.2.0",
"@types/jest": "29.2.0",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"commitizen": "^4.2.5",
"@types/jest": "29.2.4",
"@typescript-eslint/eslint-plugin": "^5.46.0",
"@typescript-eslint/parser": "^5.46.0",
"commitizen": "^4.2.6",
"cz-conventional-changelog": "^3.3.0",
"eslint": "8.25.0",
"eslint": "8.29.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jest": "^27.1.3",
"eslint-plugin-jest": "^27.1.6",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"jest": "29.2.1",
"jest-junit": "14.0.1",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"husky": "^8.0.2",
"jest": "29.3.1",
"jest-junit": "15.0.0",
"lint-staged": "^13.1.0",
"prettier": "^2.8.1",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.0",
"semantic-release-cli": "^5.4.4",
"ts-jest": "29.0.3",
"ts-loader": "^9.4.1",
"ts-loader": "^9.4.2",
"ts-node": "10.9.1",
"tsconfig-paths": "^4.1.0",
"tsconfig-paths": "^4.1.1",
"tslint-config-airbnb": "^5.11.2",
"typescript": "^4.8.4"
"typescript": "^4.9.4"
},
"peerDependencies": {
"@nestjs/common": "7.x || 8.x || 9.x",
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/pact-provider-module-options.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
import { VerifierOptions } from '@pact-foundation/pact/src/dsl/verifier/types';
import { VerifierOptions } from '@pact-foundation/pact';

export type PactProviderOptions = VerifierOptions;

Expand Down
2 changes: 1 addition & 1 deletion src/modules/pact-consumer-core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class PactConsumerCoreModule {
{
provide: useClass,
useClass,
} as ClassProvider,
},
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/pact-provider-core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class PactProviderCoreModule {
{
provide: useClass,
useClass,
} as ClassProvider,
},
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/pact-factory-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('PactFactory', () => {

describe('Given a PactFactory service', () => {
describe("When calling 'createContractBetween' method", () => {
let pact: any;
let pact: Pact;

beforeAll(() => {
pact = pactFactoryService.createContractBetween(contractBetween);
Expand Down
19 changes: 5 additions & 14 deletions src/services/pact-verifier.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,20 @@ import { PactProviderOptions } from '../interfaces/pact-provider-module-options.
@Injectable()
export class PactVerifierService {
public constructor(
@Inject(PactModuleProviders.PactVerifier) private readonly verifier: Verifier,
@Inject(PactModuleProviders.ProviderOptions) private readonly options: PactProviderOptions
@Inject(PactModuleProviders.ProviderOptions) private readonly options: PactProviderOptions,
@Inject(PactModuleProviders.PactVerifier) private readonly verifier: Verifier
) {}

public async verify(app: INestApplication): Promise<any> {
const providerUrl = new URL(this.options.providerBaseUrl);
let results: string;

await app.listen(providerUrl.port || 80, providerUrl.hostname);

// we need the try-catch here because the verifier will throw an error
// and the application will not close if the error is not caught
try {
results = await this.verifier.verifyProvider();
} catch (e) {
// do nothing
}

await app.close();
return results;
// this can throw an error, we are sure the app will close after calling finally
return this.verifier.verifyProvider().finally(() => app.close());
}

public getVerifier() {
public getVerifier(): Verifier {
return this.verifier;
}
}
Loading

0 comments on commit 486dcbe

Please sign in to comment.