A Node.js module for creating REST-style request handlers with built-in middleware support, route matching with simple path placeholders, and an event system. Version 1.2.17 uses a path-based router and encapsulates req, res, and next into a single 'rest' object, simplifying request handling compared to Express. Routes are matched before any middleware or handlers run, and unmatched routes can be handled via a 'routeNotFound' event. The package is stable but has low release cadence; it is suitable for simple REST APIs where full Express features are not needed.
npm install rest-handlerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a REST handler with a parameterized route and a 404 handler, then starts an HTTP server.
Ensure every .before() callback invokes rest.next() once processing is complete.
Always specify the HTTP method in addRoute(), or set '*' explicitly if desired.
Always pass status code as first argument: rest.error(400, 'Bad request')
Use function(req, res) { ... } for routeNotFound event handler.Use: const restHandler = require('rest-handler').create();Ensure middleware function signature is correct: function(rest) { rest.next(); }Check addRoute method field: use string like 'GET' or '*'. Omission defaults to all methods.