Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

reg-router

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reg-router

simple regex router

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

reg-router

npm version downloads js-standard-style

Just your reg router to match routes based on provided regex.

Usage

var router = require('reg-router')()

router.route(/^\/reset$/, function (req, res, params) {
  res.writeHead(200, 'reset route is hit', { 'content-encoding': 'application/json' })
}

http.createServer(function (req, res) {
  router.match(req, res)
}).listen(8080)

API

router = new Router()

Creates a new instance off reg-router.

router.route(regex, handler)

Register a new route. Handler is generally req, res, params.

router.default(handler)

Defaults to sending back a 404, but you can provide your own default. router.default will do this for you.

router.match(req, res)

Match requests to registered routes. Would usually use when server's fired up.

  • bankai
  • choo

License

MIT

FAQs

Package last updated on 21 Sep 2017

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