Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@pact-foundation/pact-node
Advanced tools
A wrapper for the Pact mock service for it to work with node in an easy to manage way.
npm install @pact-foundation/pact-node --save
Simply require the library and call the create function.
var pact = require('@pact-foundation/pact-node');
var server = pact.create({port: 9999});
server.start().then(function() {
// Do your testing/development here
});
var pact = require('@pact-foundation/pact-node');
var server = pact.create({
port: <Number>, // Port number that the server runs on, defaults to 1234
host: <String>, // Host on which to bind the server on, defaults to 'localhost'
log: <String>, // File to log output on relative to current working directory, defaults to none
ssl: <Boolean>, // Create a self-signed SSL cert to run the server over HTTPS , defaults to 'false'
cors: <Boolean>, // Allow CORS OPTION requests to be accepted, defaults to 'false'
dir: <String>, // Directory to write the pact contracts relative to the current working directory, defaults to none
spec: <Number>, // The pact specification version to use when writing pact contracts, defaults to '1'
consumer: <String>, // The name of the consumer to be written to the pact contracts, defaults to none
provider: <String> // The name of the provider to be written to the pact contracts, defaults to none
});
If you ever need to see which servers are currently created.
var pact = require('@pact-foundation/pact-node');
var servers = pact.list();
console.log(JSON.stringify(servers));
Remove all servers once you're done with them in one fell swoop.
var pact = require('@pact-foundation/pact-node');
pact.removeAll();
Start the current server.
var pact = require('@pact-foundation/pact-node');
pact.create().start().then(function(){
// Do something after it started
});
Stop the current server.
var pact = require('@pact-foundation/pact-node');
pact.create().stop().then(function(){
// Do something after it stopped
});
Stop the current server and deletes it from the list.
var pact = require('@pact-foundation/pact-node');
pact.create().delete().then(function(){
// Do something after it was killed
});
var pact = require('@pact-foundation/pact-node');
pact.create().running;
There's 3 different events available, 'start', 'stop' and 'delete'. They can be listened to the same way as an EventEmitter.
var pact = require('@pact-foundation/pact-node');
var server = pact.create();
server.on('start', function() { console.log('started'); });
server.on('stop', function() { console.log('stopped'); });
server.on('delete', function() { console.log('deleted'); });
To develop this project, simply install the dependencies and run npm run watch
to for continual development, linting and testing when a source file changes.
Running npm test
will execute the tests that has the *.spec.js
pattern.
FAQs
Core of @pact-foundation/pact. You almost certainly don't want to depend on this directly.
The npm package @pact-foundation/pact-node receives a total of 54,218 weekly downloads. As such, @pact-foundation/pact-node popularity was classified as popular.
We found that @pact-foundation/pact-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.