Registry / http-networking / rest-facade

rest-facade

JSON →
library1.16.4jsnpmunverified

rest-facade is a Node.js module designed to simplify the consumption of REST API endpoints by providing a higher-level abstraction over HTTP requests. As of version 1.16.4, it abstracts common CRUD operations (GET, POST, PUT, PATCH, DELETE) and supports dynamic URL parameters using a colon notation (e.g., `:id`). The library offers both Promise-based and callback-based interfaces for asynchronous operations, catering to different coding styles. It differentiates itself by providing a concise client abstraction for specific API paths, aiming to reduce boilerplate when interacting with structured RESTful services. The package's release cadence is effectively dormant, with the last significant update being several years ago.

npm install rest-facade
INSTALL
IMPORT
SIG · REST-FACADE
R
rest-facade
http-networkingjavascriptv1.16.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

Client
const rest = require('rest-facade'); const client = new rest.Client(...);
import { Client } from 'rest-facade';
The library exports an object with a 'Client' property via CommonJS. Direct named imports are not supported in ES Modules. The `Client` class is typically accessed as a property of the main module export.
rest
const rest = require('rest-facade');
import rest from 'rest-facade';
This package is primarily a CommonJS module. Attempting a default ESM import will likely fail or require specific ESM compatibility layers.

Demonstrates how to initialize a REST client, create a new resource, retrieve it, update it, and finally delete it using the Promise-based API.

const rest = require('rest-facade'); // Create a client for a specific API endpoint with dynamic parameters const Users = new rest.Client('http://domain.com/users/:id', { headers: { Authorization: 'Bearer my-auth-token' }, errorFormatter: { name: 'error.title', message: 'error.text' } }); const newUser = { firstName: 'Jane', lastName: 'Doe' }; // Example: Create a new user Users.create(newUser) .then(function (user) { console.log('User created:', user); // Example: Get the created user by ID return Users.get({ id: user.id }); }) .then(function (retrievedUser) { console.log('User retrieved:', retrievedUser); // Example: Update the user return Users.update({ id: retrievedUser.id }, { firstName: 'Janet' }); }) .then(function () { console.log('User updated successfully.'); // Example: Delete the user return Users.delete({ id: newUser.id }); }) .then(function () { console.log('User deleted successfully.'); }) .catch(function (error) { console.error('API operation failed:', error.message || error); });
Debug
Known issues
breakingThis package appears to be unmaintained, with its last commit over six years ago (as of April 2026) and last publish three years ago. Users should exercise caution, as it may not receive critical updates, security patches, or compatibility fixes for newer Node.js versions or dependencies. Consider alternatives for long-term projects.
fix
Migrate to an actively maintained HTTP client library like `axios`, `node-fetch`, or a more modern REST client abstraction (e.g., OpenAPI generators).
affects: >=1.0.0
gotchaThe package declares `superagent-proxy` as a peer dependency. This means users *must* explicitly install `superagent-proxy` alongside `rest-facade` for proxy functionality to work. Forgetting to install it will lead to runtime errors if proxy options are configured.
fix
Ensure `superagent-proxy` is installed: `npm install rest-facade superagent-proxy`.
affects: >=1.0.0
gotchaThis library is primarily designed for CommonJS (CJS) environments and is not officially documented or tested for use with ES Modules (ESM). Attempting to use `import` statements directly might lead to runtime errors or require specific transpilation configurations.
fix
Use `const rest = require('rest-facade');` for CJS environments. For ESM, a wrapper might be needed or consider an actively maintained ESM-compatible alternative.
affects: >=1.0.0
gotchaWhile `rest-facade` supports Promises, it also offers a callback-based API. Mixing Promises and callbacks, or relying solely on callbacks, can lead to complex error handling and 'callback hell' in modern async JavaScript.
fix
Prefer using the Promise-based API for all operations and leverage `async/await` for cleaner asynchronous code.
affects: >=1.0.0
gotchaThe library uses a colon notation (e.g., `:id`) for dynamic URL parameters. While convenient, complex parameter values (e.g., containing slashes or special characters that are part of the URL structure) might be incorrectly parsed or require careful encoding outside the library.
fix
Thoroughly test URLs with complex parameters. Ensure parameters are URL-encoded before passing them if they might contain reserved URI characters.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` in an ES Module context (`.mjs` file or `"type": "module"` in `package.json`).
fix
Convert your project to CommonJS by setting `"type": "commonjs"` in `package.json`, or use an actively maintained ESM-compatible HTTP client.
Cannot find module 'superagent-proxy'
The peer dependency `superagent-proxy` is required for proxy functionality but was not installed.
fix
Install the peer dependency: `npm install superagent-proxy`.
TypeError: rest_facade_1.Client is not a constructor
Incorrect import syntax for an old CommonJS module in an ES Module project, or incorrectly trying to destructure `Client` from `require('rest-facade')` without it being a direct named export.
fix
For CommonJS, use `const rest = require('rest-facade'); const client = new rest.Client(...);`. If in an ESM project, consider `import * as rest from 'rest-facade'; const client = new rest.Client(...);` though full compatibility with older CJS modules may vary. It's recommended to migrate to an ESM-first client.
(node:xyz) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
Lack of error handling on Promise-based API calls. The `.then()` block assumes success without handling potential rejections.
fix
Always chain a `.catch()` method to Promise calls, e.g., `UserVideos.getAll({ userId: 4 }).then(...).catch(error => console.error(error));`
Upgrade
Version history
1.16.4latest on npm
Audit
Dependencies
superagent-proxyoptionalProvides proxy support for HTTP requests; required if proxy functionality is used.
Agent activity
5 hits · last 30 days
node
4
Resources
rest-facade — npm install rest-facade · libregistry