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-at-plugin

v0.4.8

Published

凹凸租车前端egg服务插件

Readme

凹凸租车前端egg服务插件

介绍

插件整合了error log, access log, sentry, validator,并会注册健康接口/health

如何使用

首先

$ yarn add egg-at-plugin

然后进行配置

// config/config.{env}.js

config.sentry = {
  dsn: 'xxx'
}  // 添加sentry配置, 如果配置不存在则不进行注册

// config/plugin.js

exports.atPlugin = {
  enable: true,
  package: 'egg-at-plugin'
}

最后就得到了所有的功能啦~

接入

当前validator功能是需要服务自行接入的, 默认约定实现Validator Service, 实现validate方法, 方法签名为(path:string, method: string, data: any)

path为当前controller注册的路由, method为当前controller使用的http方法, data为当前参数所在区域(requestBody为body, requestQuery为不含数组的http query, requestQueries为含复数的http query)

举个🌰

// app/lib/service/validator.js
module.exports = class Validator {
  validate: (path, method, data) => {
    // some valiation here
  }
}

// app/controller/home.js

class Home extends Controller {
  // 如果当前controller 传入参数为 { light: 'blue' }, 调用方法为POST, 参数存在于HTTP body中
  async livingRoom () {
    const value = this.ctx.validator.requestBody()
    const { light } = value;
    // some bll here
  }

  // 如果当前controller 传入参数为 { knife: 'blue' }, 调用方法为GET, 参数存在于HTTP query
  async kitchen () {
    const value = this.ctx.validator.requestQuery()
    const { knife } = value;
    // some bll here
  }

  // 如果当前controller 传入参数为 { clothes: 'blue' }, 调用方法为GET, 参数存在于HTTP query 但是存在数组形式的参数
  async balcony () {
    const value = this.ctx.validator.requestQueries()
    const { clothes } = value;
    // some bll here
  }
}

sentry接入:

// config/config.{env}.js

exports.sentry = {
  dsn: 'https://819e74a6e948468b9740680cfa87986b:[email protected]/246025',
  errCallback: (err) => { // 可选
    // return 为 true 上发sentry记录, 其余忽略不进行上传, 默认只上传http code 500以上的错误及无http code的错误
    return !err.status || err.status >= 500
  }
};

// 主动上发sentry error ()

ctx.logSentryError(err) // 会自动集成当前环境上下文

// 或者

app.Raven.setContext({
  // sonme context
})
app.Raven.captureException(err, {
  // some tags
})

eureka接入:

// config/config.{env}.js
exports.eureka = {
  instance: {
    app: 'auto-node-eureka-test',
    instanceId: 'egg-eureka-pro',
    hostName: 'localhost',
    ipAddr: '127.0.0.1',
    port: {
      $: 8080,
      '@enabled': 'true',
    },
    homePageUrl: '/health',
    statusPageUrl: '/health',
    healthCheckUrl: '/health',
    secureVipAddress: '127.0.0.1',
    vipAddress: '127.0.0.1',
    dataCenterInfo: {
      '@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
      name: 'MyOwn',
    },
  },
  eureka: {
    servicePath: '/eureka/apps/',
    host: '121.199.4.107',
    port: 1246,
  },
}

TODO

  • [ ] 完善的单元测试
  • [ ] 接入apollo(egg的启动顺序坑爹啊)
  • [ ] 继续完善