
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
@saber2pr/aystore
Advanced tools
Async Store! 异步的 Store!
# from npm
npm install @saber2pr/aystore
# from github
git clone https://github.com/Saber2pr/-saber2pr-aystore.git
它是浏览器端的虚拟 server 程序
发起 http 请求,你将使用组合中间件的机制来封装接口!
它作为代理去请求后端接口.
返回 store requestListener 处理程序
const store = AyStore()
store.body()
// store.use(store.body())
注册一个 requestListener
const store = AyStore()
store.use(async ctx => {
if (ctx.request.url === '/hello') {
ctx.response.end('hello!')
}
})
在 requestListener 间传递的上下文
const store = AyStore({ name: 'aystore' })
store.use(async (ctx, next) => {
ctx.name // 'aystore'
store.context // 'aystore'
})
发起一个请求
const store = AyStore()
store.use(async ctx => {
if (ctx.request.url === '/hello') {
ctx.response.end('hello!')
}
})
store.request({ url: '/hello' }).then(res => {
console.log(res) // hello!
})
传递参数
const store = AyStore()
store.use(async ctx => {
if (ctx.request.url === '/hello') {
ctx.response.end('hello!', ctx.request.body)
}
})
store.request({ url: '/hello', body: 'world!' }).then(res => {
console.log(res) // ['hello!', 'world!']
})
Typescript 对函数参数类型默认允许双向协变,但是它不安全! 例如组合两个 AyStore 的 body 会涉及到 对 context 的依赖,如果允许双向协变,它将不会报错!
强烈建议开启:--strictFunctionTypes
{
"compilerOptions": {
"strictFunctionTypes": true
}
}
npm install
npm start
npm run dev
Author: saber2pr
you should write ts in /src
you should make test in /src/test
export your core in /src/index.ts!
FAQs
> Async Store! 异步的 Store!
The npm package @saber2pr/aystore receives a total of 4 weekly downloads. As such, @saber2pr/aystore popularity was classified as not popular.
We found that @saber2pr/aystore 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
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.