Socket
Socket
Sign inDemoInstall

router

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

router

Simple middleware-style router


Version published
Weekly downloads
718K
decreased by-2.14%
Maintainers
1
Weekly downloads
 
Created
Source

router

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

Simple middleware-style router

Installation

$ npm install router

API

var Router = require('router')

This module is currently an extracted version from the Express 4.x project, but with the main change being it can be used with a plain http.createServer object or something like connect by removing Express-specific API calls.

Documentation is forthcoming, but the Express 4.x documentation can be found at http://expressjs.com/4x/api.html#router

Example

Simple example of using the router independently of any framework.

var finalhandler = require('finalhandler')
var http = require('http')
var Router = require('router')

var router = new Router()

router.get('/', function (req, res) {
  res.setHeader('Content-Type', 'text/plain; charset=utf-8')
  res.end('hello, world!')
})

var server = http.createServer(app)

server.listen(3000, function onListening() {
  console.log('http server listening on port ' + this.address().port)
})

function app(req, res) {
  router(req, res, finalhandler(req, res))
}

Testing

$ npm test

License

MIT

FAQs

Package last updated on 20 Nov 2014

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