FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

PZBird/nodejs-router: This is an example of a simple router implementation for node.js. · GitHub

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Simple Router

Only for learning! Not for production! This is an example of a simple router implementation.

Usage

  • Copy the router.js file into you project.
  • Import this file and use it. Like:
const SimpleRouter = require("./router");
const app = new SimpleRouter();
  • Define middlewares with .use. Like:
app.use((req, res, next) => {
  console.log("Hello world!");
  next();
});
  • Define routers with .get or .post. Like:
app.post('/', (req, res, next) => {
  res.end('POST /');
});

or

app.get('/', (req, res, next) => {
  res.end('GET /');
});
  • Start the server:
app.listen(port);

Example

You can find an example of usage in the index.js file

About

This is an example of a simple router implementation for node.js.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages


Back | FazBrowse Home | New Git URL