Registry / database / sails-rest

sails-rest

JSON →
library0.1.1jsnpmunverified

A Waterline/Sails adapter for RESTful APIs, enabling Sails.js applications to interact with external HTTP services using the standard Waterline ORM interface. Version 0.1.1 (v0.1.x series) is a complete rewrite, not backwards compatible with 0.0.x. It relies on SuperAgent for HTTP requests and supports configurable before/after hooks for custom request/response transformation. Active development appears stalled; last release in 2015.

npm install sails-rest
INSTALL
IMPORT
SIG · SAILS-REST
S
sails-rest
databasejavascriptv0.1.1
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.

sails-rest
npm install sails-rest
Used as a Sails adapter; no direct JS import required. Configure in config/connections.js with adapter: 'sails-rest'

Shows minimal Sails connection config to use sails-rest adapter with a REST API.

// config/connections.js module.exports.connections = { myRest: { adapter: 'sails-rest', host: 'localhost:3000', protocol: 'http', pathname: '/api', headers: {}, hooks: { merge: true, before: [], after: [] } } }; // In a model or service User.find().exec(function(err, users) { // fetched from http://localhost:3000/api/user });
Debug
Known issues
breakingv0.1.x is a complete rewrite and not backwards compatible with v0.0.x
fix
Update configuration to match new format; see README for hooks and connection options.
affects: >=0.1.0 <0.2.0
gotchaIf hooks.merge is false, you must provide a hook that sets config.endpoint for HTTP request resolution.
fix
Either set hooks.merge: true or add a custom before hook that assigns config.endpoint.
affects: >=0.1.0
deprecatedProject is unmaintained since 2015; may not work with modern Sails/Waterline versions.
fix
Consider using a maintained adapter like sails-hook-rest or direct HTTP calls.
affects: >=0.1.0
Errors
Common errors & fixes
Error: endpoint is not defined
hooks.merge is false and no custom before hook sets config.endpoint
fix
Set hooks.merge: true in connection config, or add a before hook that defines config.endpoint.
Cannot find module 'sails-rest'
Package not installed; npm install missing
fix
Run 'npm install sails-rest' in your Sails project directory.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
superagentrequiredHTTP client for REST API calls
waterlineoptionalAdapter spec target; usually a peer dependency in Sails projects
Agent activity
7 hits · last 30 days
node
6
Meta
1
Resources
sails-rest — npm install sails-rest · libregistry