npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ppzp/controller

v0.0.1

Published

用来处理路由和 AOP

Downloads

4

Readme

一个 js 框架,两个功能:路由、AOP

npm install @ppzp/controller

皮皮仔宣言

Controller

一般来说,Controller(控制器) 经常做“页面”与“数据库”的“中间人”
比如,有个页面需要展示用户信息:

  • 页面给后台发起请求:“给我用户信息”
  • 在后台的 controller 马上就收到请求
  • 它(controller)会找到对应的代码(handler)来处理
  • 一般,这个“处理”过程,就是从数据库里拿数据
  • 取到数据后,再由 controller 送到页面上

路由

“路由”是 Controller 的一个重要功能,即要解决:

当服务器收到一条 http 请求,由哪个函数(handler),来处理这个请求

@ppzp/controller 使用了类似 express 的处理方式:

controller.post('/user', function() {
  // ...
})

AOP

不同的请求,可能需要相同的处理逻辑
代码复用是任何应用面临的重要问题
@ppzp/controller 是这样处理的:

function 公用函数(ctx, vege) {
  // ...
  vege(ctx) // 执行 vege,就是在执行下面的 handler666 函数
  // ...
}
controller.post('/user', 公用函数, function handler666(ctx) {
  // ...
})

这看起来像 express,但不同的地方在于,公用函数其实是包裹handler666 函数
比如你可以这样:

function 公用函数(ctx, vege) {
  // vege 之前,先做预处理
  const result = vege(ctx)
  // vege 之后,再做后续处理
}
controller.post('/user', 公用函数, function handler666(ctx) {
  // ...
})

就像一个三明治
上面是面包,中间是蔬菜(vegetable)或肉,下面还是面包

每一个公用函数都是一个三明治,它里面有一些蔬菜
而对公用函数“前面的”其他公用函数来说:
后面的公用函数,就是前面公用函数的“蔬菜”

使用

环境准备

仅需要一个普通的 node,最好 10 以上版本

如果没有,进入这个链接,下载相应版本

创建项目:

mkdir test-controller # 创建项目目录
cd test-controller # 进入项目目录
# 到这里,只是一个普通的文件夹

npm init -y # 使用 npm,初始化一个 node 项目
# 到这里,一个空的 node 项目就创建好了

npm install @ppzp/controller # 在项目中安装 resh

案例

TODO

API

TODO

常见问题

TODO

最后

不保留任何版权(也实在没什么好保留的)
欢迎 pr、意见、批评