Security News
NVD Halts CVE Enrichment
The NVD has stopped enriching CVE’s with little explanation, leaving the security community without metadata on 90% of records for the past month.
serverless-offline-http-mock
Advanced tools
This is a plugin for the serverless framework that provides the ability to create mock responses to HTTP(S) requests.
Weekly downloads
Readme
This is a plugin for the serverless framework that provides the ability to create mock responses to HTTP(S) requests. This is useful when developing integration against an API spec that doesn't yet exist. This plugin uses nock to provide mock responses. It supports mock requests for:
An existing serverless framework project.
npm install serverless-offline-http-mock
OR
yarn add serverless-offline-http-mock
Please note that if you installed a version of this prior to v1.0.0, you will need to follow step #2 below and add a truthy serverless-offline-http-mock-enabled
value in order for your mocks to be loaded.
Within the serverless.yml
file, enable the plugin by placing an serverless-offline-http-mock
entry in the plugins section.
If using Serverless Offline, make sure it is placed above the serverless-offline
plugin
Create a serverless-offline-http-mock-enabled
entry in the custom
section with a truthy (true, 1, etc) or falsy value (false, 0, etc). You can also use environment variables (for example, ${env:MOCK_ENABLED}
).
Create a serverless-offline-http-mock
entry in the custom
section.
For each host, create an entry containing hostname, a list of JS files to load, and an optional directory. See serverless.yml
example below.
In each JS file, export a function that accepts the nock library and hostname as arguments. Within that function, implement nock to handle the HTTP(S) requests. See example.js
example below.
serverless.yml:
...
custom:
serverless-offline-http-mock-enabled: 1
serverless-offline-http-mock:
- hostname: http://www.example.com
directory: 'mocks' # Optional
mocks:
- example.js
plugins:
- serverless-offline-http-mock # Note how this comes before serverless-offline
- serverless-offline
mocks/example.js:
const mocks = (nock, hostname) =>
nock(hostname)
.persist()
.get('/')
.reply(200, 'success!');
module.exports = mocks;
yarn test
FAQs
This is a plugin for the serverless framework that provides the ability to create mock responses to HTTP(S) requests.
The npm package serverless-offline-http-mock receives a total of 585 weekly downloads. As such, serverless-offline-http-mock popularity was classified as not popular.
We found that serverless-offline-http-mock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
The NVD has stopped enriching CVE’s with little explanation, leaving the security community without metadata on 90% of records for the past month.
Security News
The White House published its proposed budget for 2025, with $13 billion earmarked for cybersecurity and safeguarding public services.
Security News
Product
In an effort to give back to the software creators whose contributions benefit the global developer community, open source projects can now get a free upgrade to our Team plan.