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 🙏

© 2025 – Pkg Stats / Ryan Hefner

my-req-prop

v1.0.12

Published

a suite to check request property

Readme

每个key(item)的presence是

M:mandatory,必须存在  
O:optional,可存在,可不存在  
N:none,必须不存在  

CONTENT_TYPE:PRESENCE.M。

可选值:由src/data/enm中定义。注意,如果不需要设置CONTENT_TYPE(例如get请求),设置为null。  

RULE:PRESENCE.O

如果是undefined,说明对应的请求不能带任何数据(例如get请求)。    
如果不是undefined,则必须是object,且不能为空。   
- [x] 未来加上rule中字段数量的限制,最大不能超过aaa。    

RULE_BASE:PRESENCE.M,

必须存在。因为
1. rule是rule_base生成的,如果rule存在,则rule_base一定存在。  
2. rule_base还用于cipher和decipher    
以上2者相加,rule_base还是设为一定存在比较好。   

PROC_CODE:PRESENCE.M,

一定存在,且为正整数        

CIPHER:PRESENCE.O,

put/delete无需cipher,因为这2个操作返回的是 0/1(操作是否成功)。
所以设置为undefined。
如果设置了,则
1. 必须是object。    
2. 有2个字段(不能为空)。   
3. 2个字段必须是fieldInfo和dataType。   
4. fieldInfo如果设置:
    4.1 必须是Object。   
    4.2 数量不能超过2(simplex和duplex)个。    
    4.3 如果simplex或者duplex存在,则
        4.3.1 fieldInfo[simplex/duplex]必须是数组
        4.3.2 fieldInfo[simplex/duplex]的长度不能超过MAX_NUM_IN_FIELD_INFO(定义在src/data/constant)        
5. dataType必须是array或者object。        

DECIPHER:PRESENCE.M,

其实可以设计成PRESENCE.O,只要fieldInfo下simplex/duplex都是空数组,效果就等同于decipher设为undefined。但是因为偷懒,所以设成M。    
检查过程和CIPHER一样。只是最后还需要额外对get请求进行检查:get的时候,dataTypes必须是object(get请求无法携带数组)。    

PERMISSION:PRESENCE.M,

那种类型的用户允许进行此请求。    
1. 必须是数组。    
2. 数组的元素不重复。    
3. 数组的内容都是enm值。    
4. 如果元素有ANY,则数组中不用设置其他元素。    
    "ANY":'any', //任意,包含其他所有
    "USER":'user',//包括normal和shop user。session中,userId和sugar同时存在
    "NORMAL_USER":'normal_user',//普通用户(浏览,评论)
    "SHOP_USER":'shop_user',//商家用户(除了普通用户的功能,还能开店)
    "ADMIN":'admin', //session中,adminUserId和sugar同时存在
    "ANON":'anon',//匿名的,尚未登录的

VERIFY_ALL:PRESENCE.O,

判断用户是否已经通过验证。和VERIFY_ANY互斥(2个间,只能设置一个,另外一个必须undefined)     
如果设置了,则必须是数组,不能为空,且值为enm(src/data/enm)

VERIFY_ANY :PRESENCE.O,

同上。满足任意一个验证即认为已经通过验证。    

ALLOW_EMPTY:PRESENCE.O, //根据rule是否存在而是否存在。理论上不用设置

根据rule自动生成。如果rule中有任意字段的PRESENCE为M. 则此字段为false(请求输入的数据不能为空),否则为true。    

OPTIONAL_FIELDS:PRESENCE.O, //method为get,才有可能存在。用于get查询的时候,可用的查询字段

专为get请求生成。如果rule中有字段PRESENCE为O,将字段push到此字段下。

REQUIRED_FIELDS:PRESENCE.O, //method为put,才有可能存在。用于put更新时,可用的更新字段

同上,为put请求生成。   

USER_PRIVILEGE:PRESENCE.M/N,

只能设为M,或者N,而不能设为O
M:说明是普通用户的权限。    
    1. 必须是Object,key是权限名字,value暂时为{}    
    2. Object的key数量暂时为1个。  
    3. 和permission有关联,只有"user","shop_user","normal_user","admin"才需要检查权限。anon无需检查

ADMIN_PRIVILEGE:PRESENCE.M/N,

同上。    

JWT:PRESENCE.M,

APP时必须为M,值为bool,true说明请求必须带JWT,false说明请求不需要带JWT。