{"id":16196,"library":"rest-facade","title":"REST Facade Client","description":"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.","status":"abandoned","version":"1.16.4","language":"javascript","source_language":"en","source_url":"https://github.com/ngonzalvez/rest-facade","tags":["javascript","facade","rest","api"],"install":[{"cmd":"npm install rest-facade","lang":"bash","label":"npm"},{"cmd":"yarn add rest-facade","lang":"bash","label":"yarn"},{"cmd":"pnpm add rest-facade","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides proxy support for HTTP requests; required if proxy functionality is used.","package":"superagent-proxy","optional":true}],"imports":[{"note":"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.","wrong":"import { Client } from 'rest-facade';","symbol":"Client","correct":"const rest = require('rest-facade');\nconst client = new rest.Client(...);"},{"note":"This package is primarily a CommonJS module. Attempting a default ESM import will likely fail or require specific ESM compatibility layers.","wrong":"import rest from 'rest-facade';","symbol":"rest","correct":"const rest = require('rest-facade');"}],"quickstart":{"code":"const rest = require('rest-facade');\n\n// Create a client for a specific API endpoint with dynamic parameters\nconst Users = new rest.Client('http://domain.com/users/:id', {\n  headers: {\n    Authorization: 'Bearer my-auth-token'\n  },\n  errorFormatter: {\n    name: 'error.title',\n    message: 'error.text'\n  }\n});\n\nconst newUser = { firstName: 'Jane', lastName: 'Doe' };\n\n// Example: Create a new user\nUsers.create(newUser)\n  .then(function (user) {\n    console.log('User created:', user);\n    // Example: Get the created user by ID\n    return Users.get({ id: user.id });\n  })\n  .then(function (retrievedUser) {\n    console.log('User retrieved:', retrievedUser);\n    // Example: Update the user\n    return Users.update({ id: retrievedUser.id }, { firstName: 'Janet' });\n  })\n  .then(function () {\n    console.log('User updated successfully.');\n    // Example: Delete the user\n    return Users.delete({ id: newUser.id });\n  })\n  .then(function () {\n    console.log('User deleted successfully.');\n  })\n  .catch(function (error) {\n    console.error('API operation failed:', error.message || error);\n  });","lang":"javascript","description":"Demonstrates how to initialize a REST client, create a new resource, retrieve it, update it, and finally delete it using the Promise-based API."},"warnings":[{"fix":"Migrate to an actively maintained HTTP client library like `axios`, `node-fetch`, or a more modern REST client abstraction (e.g., OpenAPI generators).","message":"This 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.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure `superagent-proxy` is installed: `npm install rest-facade superagent-proxy`.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Prefer using the Promise-based API for all operations and leverage `async/await` for cleaner asynchronous code.","message":"While `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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Thoroughly test URLs with complex parameters. Ensure parameters are URL-encoded before passing them if they might contain reserved URI characters.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Convert your project to CommonJS by setting `\"type\": \"commonjs\"` in `package.json`, or use an actively maintained ESM-compatible HTTP client.","cause":"Attempting to use `require()` in an ES Module context (`.mjs` file or `\"type\": \"module\"` in `package.json`).","error":"ReferenceError: require is not defined"},{"fix":"Install the peer dependency: `npm install superagent-proxy`.","cause":"The peer dependency `superagent-proxy` is required for proxy functionality but was not installed.","error":"Cannot find module 'superagent-proxy'"},{"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.","cause":"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.","error":"TypeError: rest_facade_1.Client is not a constructor"},{"fix":"Always chain a `.catch()` method to Promise calls, e.g., `UserVideos.getAll({ userId: 4 }).then(...).catch(error => console.error(error));`","cause":"Lack of error handling on Promise-based API calls. The `.then()` block assumes success without handling potential rejections.","error":"(node:xyz) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined"}],"ecosystem":"npm"}