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

can-route

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-route

A simple router that runs inside a `http.createServer` handler and returns false when it can’t route a request.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by10%
Maintainers
1
Weekly downloads
 
Created
Source

can-route

can-route is a simple router that runs inside a http.createServer handler and returns false when it can’t route a request. Its routes are defined with named regular expressions.

Build status

Install

npm install can-route

Example

var http = require('http')
var can = require('can-route')()

// Home
can.get(/^\/$/,
  function(req, res) {
    res.end('Welcome to the homepage\n')
  }
)

// Item
can.patch(get/^\/(:<id>[a-f0-9]{16})\/?$/i,
  function(req, res, params) {
    res.end(params.id + '\n')
  }
)

// Server
http.createServer(function(req, res) {
  if (!can.route(req, res)) {
    res.statusCode = 404
    res.end()
  }
}).listen(8080)

License

MIT

Keywords

FAQs

Package last updated on 28 Oct 2013

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