Catalog npm
Back to packageRELEASE DETAILS

1.3.1

npm

3h-router

A simple router.

3hrouterouterserver
Published5 Feb 2018
Direct dependencies0
Transitive dependenciesNot calculated

README

Current package documentation

3h-router

A simple router lib.

Features

  • Gzip/Deflate support
  • Main router and sub-routers

Example

main router


const Router = require('3h-router'),
    router = new Router({ basePath: __dirname });

// You can get default values via Router.defaultOptions.
router.defaultPages.unshift('my-default-page.html');
router.subRouters.unshift('my-sub-router.js');

router.on('before', url => {
    console.log(`[before] ${url}`);
    // If there's any `before` event handler, then
    // the routing will pause here, so remember to
    // call router.route to continue the routing.
    // In addition, if you want to forward the
    // request, then just pass the target url.
    router.route(url);
}).on('result', result => {
    console.log(`[result] ${result.code}`);
}).on('error', err => {
    console.log('An error occurred!');
    console.error(err);
}).start(88);

console.log('Server started on port 88!');

sub-router


module.exports = router => {
    const { response } = router;
    response.writeHead(200, {
        'Content-Type': 'text/html'
    });
    response.end('<h1>Generated by sub-router!</h1>');
};

APIs

Just read the declaration files in typings to learn the APIs.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 0

Native requirements
0 direct targetsNot calculated transitive count
No declared dependencies in this collected response

Declarations describe requirements; they are not a resolved dependency graph.

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-gESj4FwOw0epJIWO6N6TDZl1ORss3T/rHI0uEHXVgaDeDBPM/cANWqhznBdv8ozY6fbn5Hk1OlYGt+ZhFkga8A==",
  "shasum": "5df8ebbb31dae0de39a4a0006468940665682715",
  "tarball": "https://registry.npmjs.org/3h-router/-/3h-router-1.3.1.tgz",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQCR6+s2tJZBVM/3Jyp5QetnsRW7i5wtGRxthHma2lfmMgIhAOlvdbRVAcMaSWbx4xFtNd9O8iinAVlzXCH8m9grFm74"
    }
  ]
}

Repository

PENDING
huang2002/3h-router

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:43 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:ac66a9368c888fdc17d1a881a804074526a07d4bbce4d274bc1300a9f2c0af23

Other collected versions

2.0.57 Sept2.0.47 Jul2.0.323 Jun2.0.223 Jun2.0.123 Jun1.8.18 MarView all collected versions →