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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ette-router

v1.0.3

Published

[![Build Status](https://travis-ci.org/boycgit/ette-router.svg?branch=master)](https://travis-ci.org/boycgit/ette-router) [![Coverage Status](https://coveralls.io/repos/github/boycgit/ette-router/badge.svg?branch=master)](https://coveralls.io/github/boycg

Downloads

25

Readme

ette-router

Build Status Coverage StatusMIT Licence npm version

Router middleware for ette.

  • written in Typescript
  • used with koa style
  • fully tested

Installation

Node.js / Browserify

npm install ette-router --save
var Router = require('ette-router');

Global object

Include the pre-built script.

<script src="./dist/index.umd.min.js"></script>

Build & test

npm run build
npm test

Usage

param

example: https://repl.it/@boycgit/ette-router-param

test your router rule: http://forbeslindesay.github.io/express-route-tester/

document

npm run doc

then open the generated out/index.html file in your browser.

注:你写路由匹配规则时的 / 是很重要的,但你在用 request 方法中的 path 里的 / 则是无关紧要的;

你需要区分 路由规则中间件 这两个概念。

直接使用 use 的是 中间件

router.use('/', function(ctx, next) {
    // your code...
    return next();
});

使用 HTTP.verb() 的时候,定义的则是 路由规则

router.get('/', function(ctx, next) {
    // your code...
    return next();
});

路由规则 本质上也是中间件

在代码层面,这部分差别是在 Router#match() 方法返回的 MatchedRouter 类型的 route 属性是否是 true 来区分的,如果为 true 表示路由规则,如果是 false 表示定义是中间件

注意:只有当匹配路由规则的时候才会运行相关的中间件,匹配中间件上的 path 并不会运行中间件!!

License

MIT.