From Node Package Manager:
npm install node-simple-router
From source:
git clone https://github.com/sandy98/node-simple-router
cd to your installation directory and runnpm test
then point your browser to http://localhost:8000 and review the info
and above all, try the examples.
You can roll your own, or use the sample server that NSR provides by means of the mk-server utility:
mk-server js
will provide a barebones server (server.js) with some example routes ready to run.
In order for this to work, you must have installed NSR global, like so:
sudo npm install -g node-simple-router
, or have the .bin directory of NSR in your path by whatever means you see fit.
Either case, the basic steps are the same:
var http = require('http');
var Router = require('node-simple-router');
var router = Router(); // may also be router = new Router();
router.get("/hello", function(request, response) {response.end("Hello, World!"};});
var server = http.createServer(router);
server.listen(1234);