{"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.","language":"javascript","status":"abandoned","last_verified":"Tue Apr 21","install":{"commands":["npm install rest-facade"],"cli":null},"imports":["const rest = require('rest-facade');\nconst client = new rest.Client(...);","const rest = require('rest-facade');"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}