Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ette-router

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ette-router

[![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

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 16 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc