2.0.1 • Published 4 years ago

easy-simple-router v2.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

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.
2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago