1.3.1 • Published 8 years ago

vien-simple-router v1.3.1

Weekly downloads
2
License
ISC
Repository
github
Last release
8 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

8 years ago

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago