1.0.4 • Published 5 years ago

httprouter-js v1.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

HttpRouter

NPM Version Node Version

Super fast web router for node.js, rewritten from golang's httprouter

Installation

npm i httprouter-js -S

Usage

import { createServer, IncomingMessage, ServerResponse } from "http";
import { Router } from "httprouter-js";

const router = new Router();

function Index(res: ServerResponse, req: IncomingMessage, params: any) {
  res.write(
    "Welcome! " +
      (params ? params.find((v: any) => v.Key === "name").Value : "")
  );
  res.end();
}

router.GET("/another", Index);
router.GET("/hello/:name", Index);

const server = createServer(router.ServeHTTP.bind(router));

server.listen(3000);
console.log("Listening on 3000..");

Todo

  • middleware
  • adapter for express or koa

License

MIT

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago