Socket
Socket
Sign inDemoInstall

agnostic-router

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agnostic-router

Route URLs without requiring Express and friends


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

Agnostic Router

Route without Express and friends

Installation

Bower

bower install

Node

npm install

Usage

Load in Node.js:

var router = require('agnostic-router')();

Load in browser:

var router = Router();

router.use(function(request, respond, next) {
	console.log("All requests will pass through here");
	next();
});

router.use('/papers', function(request, respond, next) {
	console.log("This should not be triggered at all");
	next();
});

router.use('/books', function(request, respond, next) {
	console.log("All requests under /books will pass through here");
	next();
});

router.method('request', '/books/mybook', function(request, respond, next) {
	console.log("Requests to /books/mybook will pass through here");
	respond(null, "ok");
});

router.route('request', '/books/mybook', {}, function(error, response) {
	console.log("RESPONSE", error, response);
}, function() {
	console.log("This will be triggered if none of the routers are triggered");
});

// Build a path
var generated = router.path('/books/:category/:title', {category: 'mycategory', title: 'mytitle'});

Testing

mocha test/*

FAQs

Package last updated on 19 Aug 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

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