Registry / devops / rest-library

rest-library

JSON →
library1.2.3jsnpmunverified

rest-library v1.2.3 is a small Node.js library for creating REST applications with express-like middleware. It provides a lightweight alternative to Express with a similar middleware pattern, supporting HTTP method routing, path parameters, and patterns. The library ships TypeScript types and includes utilities like a body parser. It requires Node.js >=14.19.2 and is ESM-first. The package appears to be stable with low release cadence. Key differentiators include simplicity and zero dependencies, but it lacks the ecosystem and community support of larger frameworks.

npm install rest-library
INSTALL
IMPORT
SIG · REST-LIBRARY
R
rest-library
devopsjavascriptv1.2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Rest
import Rest from 'rest-library'
const Rest = require('rest-library')
The package is ESM-only (package.json "type": "module") and exports a default class.
parseBodyMiddleware
import { parseBodyMiddleware } from 'rest-library/utils.js'
import { parseBodyMiddleware } from 'rest-library'
Utilities are in a separate subpath export; must include the full path with .js extension.
RestLib
import type { RestLib } from 'rest-library'
TypeScript users can import the class type for type annotations. The package ships TypeScript types.

Create a basic REST server with middleware and a GET route.

import Rest from 'rest-library'; const app = new Rest(); app.use((ctx, next) => { console.log(`${ctx.request.method}: ${ctx.request.url}`); next(); }); app.get('/', (ctx) => { ctx.response.send('Hello world'); }); app.listen(3000, () => console.log('Server started on port 3000'));
Debug
Known issues
breakingThis library is ESM-only and cannot be used with CommonJS require().
fix
Use import syntax or ensure your project is configured for ESM (e.g., type: module in package.json).
affects: >=1.0
gotchaThe body parser middleware only supports application/json and text/plain Content-Types.
fix
Use middleware like busboy for multipart/form-data or other types.
affects: >=1.0
gotchaThe path /file/* matches /file/1, /file/1/2, but also matches /file/ without additional segments? Check docs.
fix
Test your routes thoroughly; use explicit patterns if needed.
affects: >=1.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/rest-library/src/index.js from /path/to/project/app.js not supported.
The package is ESM-only and you are using require().
fix
Use import Rest from 'rest-library' instead of require().
TypeError: app.use is not a function
Missing 'new' keyword when instantiating Rest, or incorrect import.
fix
Use const app = new Rest();
SyntaxError: The requested module 'rest-library/utils.js' does not provide an export named 'parseBodyMiddleware'
Using wrong import path or missing file extension.
fix
Import with full path including .js: import { parseBodyMiddleware } from 'rest-library/utils.js'
Upgrade
Version history
1.2.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
rest-library — npm install rest-library · libregistry