1.1.5 • Published 22 days ago

rustling-river-routes v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
22 days ago

Rustling River Routes

A lightweight routing library for Node.js applications, inspired by the simplicity and flexibility of Express.js but tailored for smaller scale projects.

Features

  • Simple API for route handling.
  • Supports dynamic route parameters.
  • Query string parsing.
  • Lightweight with minimal dependencies.

Installation

npm install rustling-river-routes

Usage

Initialize your router and define routes like so:

const RustlingRiverRoutes = require('rustling-river-routes');
const http = require('http');

const router = new RustlingRiverRoutes();

router.add('/user/:id', (req, res, params) => {
  res.end(`User ID: \${params.id}`);
});

const server = http.createServer((req, res) => {
  router.handle(req, res);
});

server.listen(3000, () => {
  console.log('Server listening on port 3000');
});

Handling 404 Not Found

Rustling River Routes emits an 'error' event for handling 404 errors or other types of exceptions:

router.on('error', (error, req, res) => {
  res.statusCode = error.status || 500;
  res.end(error.message);
});

License

This project is licensed under the MIT License.

1.1.5

22 days ago

1.1.4

22 days ago

1.1.3

2 months ago

1.1.2

2 months ago