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-facadeVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize a REST client, create a new resource, retrieve it, update it, and finally delete it using the Promise-based API.
Migrate to an actively maintained HTTP client library like `axios`, `node-fetch`, or a more modern REST client abstraction (e.g., OpenAPI generators).
Ensure `superagent-proxy` is installed: `npm install rest-facade superagent-proxy`.
Use `const rest = require('rest-facade');` for CJS environments. For ESM, a wrapper might be needed or consider an actively maintained ESM-compatible alternative.Prefer using the Promise-based API for all operations and leverage `async/await` for cleaner asynchronous code.
Thoroughly test URLs with complex parameters. Ensure parameters are URL-encoded before passing them if they might contain reserved URI characters.
Convert your project to CommonJS by setting `"type": "commonjs"` in `package.json`, or use an actively maintained ESM-compatible HTTP client.
Install the peer dependency: `npm install superagent-proxy`.
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.Always chain a `.catch()` method to Promise calls, e.g., `UserVideos.getAll({ userId: 4 }).then(...).catch(error => console.error(error));`