Skip to content

JonnyJong/http-matcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http-matcher

Simple wrapper for node:http to handle different page requests by using matcher and responder.

Usage

const { Server, tryPort } = require('../dist/index');

(async ()=>{
  if (!(await tryPort(80))) {
    throw new Error('Port Occupancy.');
  }

  let server = new Server(80);
  server.defaultResponser = (req, res)=>{
    // Using node's API
    res.statusCode = 200;
    res.write(/* HTML */);
    res.end();
  };

  server.setHandler(/\/page*/, (req, res)=>{
    // Other page's responser
  });
})();

Build

npm install
tsc

About

Simple wrapper for node:http to handle different page requests by using matcher and responder.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published