Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (isEmpty(this.opts.provider)) {
throw new Error("You must specify a Provider for this pact.");
}
this.server = serviceFactory.createServer({
cors: this.opts.cors,
dir: this.opts.dir,
host: this.opts.host,
log: this.opts.log,
port: this.opts.port,
spec: this.opts.spec,
ssl: this.opts.ssl,
sslcert: this.opts.sslcert,
sslkey: this.opts.sslkey,
});
serviceFactory.logLevel(this.opts.logLevel);
logger.info(`Setting up Pact with Consumer "${this.opts.consumer}" and Provider "${this.opts.provider}"
using mock service on Port: "${this.opts.port}"`);
this.mockService = new MockService(this.opts.consumer, this.opts.provider, this.opts.port, this.opts.host,
this.opts.ssl, this.opts.pactfileWriteMode);
}
constructor(private config: MessageProviderOptions) {
if (config.logLevel && !isEmpty(config.logLevel)) {
serviceFactory.logLevel(config.logLevel)
logger.level(config.logLevel)
} else {
logger.level()
}
}
constructor(private config: MessageProducerOptions) {
serviceFactory.logLevel(this.config.logLevel);
}
constructor(private config: MessageConsumerOptions) {
if (!isEmpty(config.logLevel)) {
serviceFactory.logLevel(config.logLevel);
}
}
const spec = opts.spec || 2
const cors = opts.cors || false
const pactfileWriteMode = opts.pactfileWriteMode || 'overwrite'
const server = serviceFactory.createServer({
host: host,
port: port,
log: log,
dir: dir,
spec: spec,
ssl: ssl,
sslcert: sslcert,
sslkey: sslkey,
cors: cors
})
serviceFactory.logLevel(logLevel)
logger.info(`Setting up Pact with Consumer "${consumer}" and Provider "${provider}" using mock service on Port: "${port}"`)
const mockService = new MockService(consumer, provider, port, host, ssl, pactfileWriteMode)
/** @namespace PactProvider */
return {
/**
* Start the Mock Server.
* @returns {Promise}
*/
setup: () => net.isPortAvailable(port, host).then(() => server.start()),
/**
* Add an interaction to the {@link MockService}.
private setConfig(config: VerifierOptions) {
this.config = config
if (this.config.logLevel && !isEmpty(this.config.logLevel)) {
serviceFactory.logLevel(this.config.logLevel)
logger.level(this.config.logLevel)
}
this.deprecatedFields.forEach(f => {
if ((this.config as any)[f]) {
logger.warn(
`${f} is deprecated, and will be removed in future versions`
)
}
})
if (this.config.validateSSL === undefined) {
this.config.validateSSL = true
}
if (this.config.changeOrigin === undefined) {
constructor(config: PactOptions) {
this.opts = Pact.createOptionsWithDefaults(config)
if (isEmpty(this.opts.consumer)) {
throw new ConfigurationError("You must specify a Consumer for this pact.")
}
if (isEmpty(this.opts.provider)) {
throw new ConfigurationError("You must specify a Provider for this pact.")
}
logger.level(this.opts.logLevel as LogLevels)
serviceFactory.logLevel(this.opts.logLevel)
this.createServer(config)
}