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

@twesix/express-auto-route

v2.0.3

Published

[![npm badge](https://img.shields.io/npm/v/@twesix/express-auto-route.svg?style=flat-square)](https://www.npmjs.com/package/@twesix/express-auto-route) [![npm downloads](https://img.shields.io/npm/dm/@twesix/express-auto-route.svg?style=flat-square)](htt

Readme

express-auto-route

npm badge npm downloads license

基于express的简易自动化应用配置框架

安装

npm install --save @twesix/express-auto-route

用途

在使用express开发后台应用的过程中,总是会去做一些重复性的工作,比如配置路由,中间件,异常和错误处理。 为了简化开发过程,减少代码的重复,我把在使用express时的一些公共代码抽出来,写成了这个独立的模块。

导入了这个框架之后, 再基于express开发应用时只需要编写对应路径的处理函数 路径的配置, 错误的处理都不再需要去关注

用法

const ear = require('./index')

const app = ear()
// app 就是 express() 的返回对象
// 只不过添加了一些常用方法

// setup your app
app.set('trust proxy', true)

// app.$setCgiRoot('handlers') // 默认就是 'handlers', 可以改为其他目录

// 注入到res对象上面的属性, 方便在handler中调用
app.$addInjection('$testInjection', 'test injection')

// 默认监听10000端口, 127.0.0.1本地地址
app.$start()

handler的编写

// handlers 目录内部每一个文件都会被映射到路径上去
// 每个文件都是一个路径对应的处理模块
// 每个文件的module.exports.POST必须是数组或者函数
// 
// 如果是函数, 这直接执行, 这个函数必须调用res.$ok 或者res.$error来结束这次请求, 否则就会一直没有响应, 直到连接超时
// 如果是数组, 则会依次执行数组内的函数, 除了最后一个函数外, 每个函数有3个参数(req, res, next), 如果不调用next的话, 代表后面的函数不执行了, 必须调用res.$ok 或者res.$error来结束请求, 否则就会一直没有响应, 直到连接超时
// module.exports.params是一个对象, 代表这个路径的请求需要的参数, 框架会在调用handler之前自动进行参数检查, 用法详见示例

// return_body.js
module.exports.post = function(req,res)
{
    const data = {
        body: req.body,
        $testInjection: res.$testInjection // 在这里使用之前注入res对象的属性
    }
    res.$ok(data)
}

module.exports.params = {
    bar: true
}