1.3.1 • Published 10 years ago

vien-simple-router v1.3.1

Weekly downloads
2
License
ISC
Repository
github
Last release
10 years ago

#My Simple Router (as an exercise, don't actually use it)

Install the npm package from terminal

npm i --S vien-simple-router

Require in the http module

const http = require('http')

Require the router module

const Router = require('vien-simple-router')

Construct a new Router object with a root path

let router = new Router('/api');

Define the routes

router.get('/hello', (req, res) => {
  res.writeHead(200, {
    'Content-Type': 'application/json'
  });
  res.write('{"msg": "hello world"}');
  res.end();
});

Start and tell the server to listen to a specific port

http.createServer(router.route()).listen(port)
1.3.1

10 years ago

1.3.0

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago