easy-simple-router

2.0.1 • Public • Published

Easy Simple Router

This package was made to make adding routes easy and simple.

routes = {
  "/": {
    "GET /": sendMessage("This is my api"),
    "/math": {
      "GET /": sendMessage("This does math"),
      "POST /multiply-numbers": multiplyNumbers,
      "POST /add-numbers": addNumbers,
    },
  },
  "ALL *": sendMessage("Invalid Route")
};
router.use( "/", require("easy-simple-router")(routes) );

Getting Started

Install

npm install easy-simple-router

Usage

The image above mostly explains it. There is an example project on GitHub. Extra info:

  • Put the http method and url as the key (ex. "GET /") and the function you want to call as the value.
  • You can put any number of http methods by seperating them with "/" (ex. "GET/POST /").
  • If you don't put an http method (ex. "/") you can nest.

Package Sidebar

Install

npm i easy-simple-router

Weekly Downloads

0

Version

2.0.1

License

ISC

Unpacked Size

2.48 kB

Total Files

3

Last publish

Collaborators

  • zerovocabulary