Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@bbc/http-transport
Advanced tools
A flexible, modular REST client built for ease-of-use and resilience.
A flexible, modular REST client built for ease-of-use and resilience
npm install @bbc/http-transport --save
const url = 'http://example.com/';
const client = require('@bbc/http-transport').createClient();
const res = await client
.get(url)
.asResponse();
if (res.statusCode === 200) {
console.log(res.body);
}
For more examples and API details, see API documentation
Types are included in this project, and they also work with plugins.
Just pass the types that your plugin will add to context
as a generic. This will be overlayed on top of any types added by previous plugins in the chain.
E.g.
const addSessionData: Plugin<{ session: { userId: string } } }> = (context, next) => {
context.session = { userId: 'some-user' };
};
const res = await client
.use(addSessionData)
.use((context, next) => {
if (context.session.userId === 'some-user') { // this would error if addSessionData middleware was missing
// do something
}
})
.use<{res: { random: number } }>((context, next) => {
context.res.random = Math.random();
})
.get(url)
.asResponse();
console.log(res.random); // number
If you don't want to type your plugin, simply use any
as the type. This is not recomemnded though as it means all plugins later in the chain will loose the types too, because they have no idea what changes were made.
const myPlugin: Plugin<any> = (context, next) => {};
npm test
To generate a test coverage report:
npm run coverage
FAQs
A flexible, modular REST client built for ease-of-use and resilience.
The npm package @bbc/http-transport receives a total of 863 weekly downloads. As such, @bbc/http-transport popularity was classified as not popular.
We found that @bbc/http-transport demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.