New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

anumargak

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anumargak

Amazing fast HTTP router

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by28.57%
Maintainers
1
Weekly downloads
 
Created
Source

anumargak (अनुमार्गक)

Fast HTTP Router

Known Vulnerabilities Travis ci Build Status Coverage Status bitHound Dev Dependencies bitHound Overall Score NPM total downloads

Become a Patron! Stubmatic donate button

Usage

const router = require('anumargak')({
  defaultRoute : defaultHandler,
  ignoreTrailingSlash: true
});
anumargak.on("GET", "/this/is/static", handler);
anumargak.on("GET", "/this/is/:dynamic", handler);
anumargak.on("GET", "/this/is/:dynamic", handler);//it will overwrite old mapping
anumargak.on("GET", "/this/is/:dynamic/with/:pattern(\\d+)", handler);
//Eg: params = { dynamic : val, pattern: 123}
anumargak.on("GET", "/this/is/:dynamic/with/:two-:params", handler);//use - to separate multiple parameters
anumargak.on("GET", "/this/is/:dynamic/with/:two(\\d+):params", handler);
anumargak.on("GET", "/this/is/:dynamic/with/:two(\\d+)rest", handler);
anumargak.on("GET", "/similar/:string([a-z]{10})", handler);
anumargak.on("GET", "/similar/:number([0-9]{10})", handler);//above route is different from this


anumargak.find("GET","/this/is/static");//will return handler
anumargak.find("GET","/this/is/dynamic/with/123?ignore=me");//ignore query parameters and hashtag part automatically

anumargak.lookup(req,res) ;//will execute handler with req,res and params(for dynamic URLs) as method parameters

wildcard: I couldn't understand the need of wildcard, hence not implemented. Please raise the issue if it should be implemented.

Example with server

const http = require('http')
const router = require('anumargak')()

router.on('GET', '/', (req, res, params) => {
  //process the request response here
})

const server = http.createServer((req, res) => {
  router.lookup(req, res)
})

server.listen(3000, err => {
  if (err) throw err
  console.log('Server listening on: http://localost:3000')
})


Benchmark

methodurl typeanumargak (अनुमार्गक)find-my-way
findstatic32111671.232939447.287
finddynamic2767738.281220416.079
findwith query param1735181.4861178885.798
lookupstatic29686926.232288805.684
lookupdynamic2034493.0621023664.399
lookupwith query param1414253.913 894684.0352

Note : Above benchmark has been taken on 16gb RAM ubuntu machine with node v9.5.0 and npm v5.6.0

chart

Worth to mention

  • NIMN निम्न : Schema aware object compression. 60% more compressed than JSON. 40% more compressed than msgpack.
  • imglab : Web based tool to label images for object detection. Use it to train dlib or other object detectors. Integrated with 3rd party libraries to speed up tp process and to make you lazy.
  • fast-lorem-ipsum : Generate lorem ipsum words, sentences, paragraph very quickly. Pure JS implementation.
  • stubmatic : A stub server to mock behaviour of HTTP(s) / REST / SOAP services. You can easily mock msgpack, and nimn data formats as well.
  • fast-xml-parser : Pure JS implementation to parse XML to JSON, JS Object, or Nimn format. Parse back from JSON, JS Object to XML. Or just validate XML syntax.
  • Grapes : Flexible Regular expression engine (for java) which can be applied on char stream. (under development)
  • Muneem (मुनीम): A framework to write fast web services in easy way. Designed specially for developers, QAs, Maintainers, and BAs.

Keywords

FAQs

Package last updated on 23 Mar 2018

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