3.0.3 • Published 5 months ago

@routejs/router v3.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

NPM Version NPM Install Size NPM Downloads

Routejs is a fast and lightweight http routing engine for Node.js

Features

  • Fast and lightweight
  • Group based routing
  • Host based routing
  • Named routing
  • Middleware support
  • Object and array based routing
  • Regular expression support

Installation

Install using npm:

$ npm i @routejs/router

Install using yarn:

$ yarn add @routejs/router

Example

const { Router } = require("@routejs/router");
const http = require("http");

const app = new Router();

app.get("/", function (req, res) {
  res.end("Ok");
});

// Create 404 page not found error
app.use(function (req, res) {
  res.writeHead(404).end("404 Page Not Found");
});

http.createServer(app.handler()).listen(3000);

Url route example

Routejs is very simple and flexible, it support both object and array based url routing.

Let's create urls.js urls file for routes:

const { path, use } = require("@routejs/router");

// Url routes
const urls = [
  path("get", "/", (req, res) => res.end("Ok")),
  // Create 404 page not found error
  use((req, res) => res.writeHead(404).end("404 Page Not Found")),
];

module.exports = urls;

Use urls in routejs app:

const { Router } = require("@routejs/router");
const http = require("http");
const urls = require("./urls");

const app = new Router();

// Use url routes
app.use(urls);

http.createServer(app.handler()).listen(3000);

Documentation

License

MIT License

3.0.3

5 months ago

3.0.2

5 months ago

3.0.1

5 months ago

3.0.0

5 months ago

2.1.8

1 year ago

2.1.7

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago