Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
A utility that uses local storage to mock servers. Currently, it assumes the same API as fancy-fetch as I intend to use it as a drop-in replacement with that library, though I'd like for it support raw fetch as well in the future.
import fauxFetch from 'faux-fetch'
// Puts an entry into local storage
fauxFetch({
url: '/me',
method: 'put',
body: { name: 'Smeagol' }
success: (result) => {
console.log(result) // { name: 'Smeagol' }
}
})
// Get an entry from local storage
fauxFetch({
url: '/me',
success: (result) => {
console.log(result) // { name: 'Smeagol' }
}
})
In the real world, it takes some time for these requests to occur. fauxFetch uses setTimeout
with a default delay of 200ms. You can provide your own custom delay, along with many other options, within the object passed to fauxFetch.
url
: Stringbody
: Object|String|Null (anything JSON.parse
able)success
: Functionerror
: Functiondelay
: Numbercustom
: ObjectIf you do not provide a url
parameter in these options, fauxFetch will give you a partially applied function, this will let you configure fetch how you please. For example:
const ImmediateFetch = fauxFetch({ delay: 0 })
Will give you a faux fetcher that does not wait the default 200ms. You might want to customize how your server API works, however:
const customFetch = fauxFetch({
custom: {
'/me/get_ring': {
'post': () => {
immediateFetch({
url: '/me',
method: 'post',
body: { age: 'old', name: 'Gollum' }
})
}
}
}
})
customFetch({
url: '/me',
success: (result) => {
console.log(result) // { name: 'Smeagol' }
}
})
customFetch({ url: '/me/get_ring' })
customFetch({
url: '/me',
success: (result) => {
console.log(result) // { name: 'Gollum', age: 'old' }
}
})
I'm still working on making this cleaner.
FAQs
A utility for faking fetch requests
The npm package faux-fetch receives a total of 1 weekly downloads. As such, faux-fetch popularity was classified as not popular.
We found that faux-fetch 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.