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

egg-visit

v1.0.5

Published

集访问日志,gzip,error,mock,proxy 一体的 egg 插件

Readme

egg-visit

version MIT PRs Welcome

支持

app.js 使用 class 形式 所以你需要更新你的 egg 版本 2.14.2 以上

快速开始

npm install egg-visit --save

API

// 默认配置
visit:{
  proxy: {
    enabled: false,
    timeout: 3000,
    list: [],
  },
  router:{ 
    dir: path.join(this.app.baseDir, 'app/router'),
    enabled: true,
  },
  access: {
    enabled: true,
    ignore: []
  },
  gzip: {
    enabled: true,
    threshold: 1024
  },
  error: {
    enabled: true,
  }
}
exports.visit = {
  enable: true,
  package: 'egg-visit'
};

提供的方法

app

  • app.uuid()
  • app.encrypt('xxx') // config.keys 数组的第一个或字符串 为加密 key
  • app.decrypt('xxx')

ctx

  • ctx.json.success
ctx.json.success({
  msg:'', // 默认 '请求成功'
  code:200, // 默认 200
  data:'', // 默认 ''
  obj:{total:1}, // 默认 {}
}) 
// return 
{
  msg:'',
  data:'',
  total:1,
  code:200,
  success: true
}
  • ctx.json.error
ctx.json.error({
  msg:'', // 默认 '请求失败'
  data:'', // 默认 ''
  code:200, // 默认 200
}) 
// return 
{
  msg:'',
  data:'',
  code:200,
  success: false
}

request

  • acceptJson // 判断是否为json
ctx.request.acceptJson // true/false

router

app/router 文件夹下的 router 配置自动读取

//app/router/x.js

module.exports = app => {
  const {router, controller} = app;
  const {testController} = controller;
  router.post(`/test`, testController.test);
};

mock

app/mock 文件夹下的 mock 自动生成 mock API

//app/mock/get/user.js

const Mock = require('mockjs');
module.exports = Mock.mock({
  'success': true,
  'code': 200,
  'data': {
    id: '@id',
    title: '@cparagraph(2)',
    sub_title: '@cparagraph(3)',
    label: '@ctitle(2,4)',
    link_url: '@cparagraph(2)',
    banner_url: '@image(720x480,@color)',
    update_time: '@datetime',
    content: '@cparagraph(30)'
  }
});

// 生成的 API 为 GET /user 
// 支持多级目录 app/mock/get/user/detail.js --> GET /user/detail 
// 支持GET、POST、PUT、DELETE

proxy

proxy: {
  enabled: false,
  timeout: 3000,
  list: [
    {
      from '/api',
      target: 'http://127.0.0.1:8080'
    }
  ],
},