Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove consumer/provider as options in PactWeb as they are dep… #432

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 42 additions & 9 deletions src/pact-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,49 @@
import { polyfill } from "es6-promise"
import { isEmpty } from "lodash"
import { Interaction, InteractionObject } from "./dsl/interaction"
import { MockService } from "./dsl/mockService"
import { PactOptions, PactOptionsComplete } from "./dsl/options"
import { MockService, PactfileWriteMode } from "./dsl/mockService"
import { PactOptions, LogLevel, MandatoryPactOptions } from "./dsl/options"
import VerificationError from "./errors/verificationError"
polyfill()

export interface PactWebOptions {
// The port to run the mock service on, defaults to 1234
port?: number

// The host to run the mock service, defaults to 127.0.0.1
host?: string

// SSL flag to identify the protocol to be used (default false, HTTP)
ssl?: boolean

// Path to SSL certificate to serve on the mock service
sslcert?: string

// Path to SSL key to serve on the mock service
sslkey?: string

// Directory to output pact files
dir?: string

// Directory to log to
log?: string

// Log level
logLevel?: LogLevel

// Pact specification version (defaults to 2)
spec?: number

// Allow CORS OPTION requests to be accepted, defaults to false
cors?: boolean

// Control how the Pact files are written
// (defaults to 'overwrite')
pactfileWriteMode?: PactfileWriteMode
}

export type PactWebOptionsComplete = PactOptions & MandatoryPactOptions

/**
* Creates a new {@link PactWeb}.
* @memberof Pact
Expand All @@ -22,7 +60,7 @@ polyfill()
export class PactWeb {
public mockService: MockService
public server: any
public opts: PactOptionsComplete
public opts: PactWebOptionsComplete

constructor(config?: PactOptions) {
const defaults = {
Expand All @@ -36,12 +74,7 @@ export class PactWeb {
ssl: false,
} as PactOptions

this.opts = { ...defaults, ...config } as PactOptionsComplete

if (!isEmpty(this.opts.consumer) || !isEmpty(this.opts.provider)) {
console.warn(`Passing in consumer/provider to PactWeb is deprecated,
and will be removed in the next major version`)
}
this.opts = { ...defaults, ...config } as PactWebOptionsComplete

console.info(
`Setting up Pact using mock service on port: "${this.opts.port}"`
Expand Down