New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

endpointsjs

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

endpointsjs

Simple helper functions for service client implementation

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22
increased by29.41%
Maintainers
1
Weekly downloads
 
Created
Source

Endpoints

Build Status

Simple helper library for your REST service clients.

Install it

npm install endpointsjs

Usage

Use Endpoints to create an endpoint pattern, then call methods on that pattern to get promises back. Simple as that.

var Endpoints = require('endpointsjs');

var myEndpoint = new Endpoints.GetPost({
  url: '/some/url',
  dataType: 'json'
});

var promiseCallback = function(endpoint) {
  console.log(endpoint.data);
  assert(endpoint === myEndpoint);
};

myEndpoint.get()
.then(promiseCallback);

It is also possible to create a custom endpoint pattern.

var Endpoints = require('endpointsjs');

var myOtherEndpoint = new Endpoints.Custom({
  url: '/some/other/url',
  methodList: ['options', 'post', 'delete']
});

var promiseCallback = function(endpoint) {
  console.log(endpoint.data);
};

myOtherEndpoint.post({data: {myData: 123}})
.then(promiseCallback)
.then(myOtherEndpoint.delete);

Underneath Endpoints is using jQuery.ajax, so the options hash sent to Endpoints.Whatever will take any valid jQuery.ajax option.

Available Endpoint Patterns

GetPost [GET, POST, OPTIONS]
GetPutDelete [GET, PUT, DELETE, OPTIONS]
GetPut [GET, PUT, OPTIONS]
Custom options.methodList

Is Endpoints Right for my API?

Endpoints makes assumptions about APIs and Services. Most of these assumptions are derived from the REST style architecture. Here is a list of them:

  • APIs are stateless
  • API endpoints return a resources representation after GET, POST, or PUT
  • Content-Type is specified in the response
  • Your API makes JSON and/or XML first class citizens

If your API does not closely follow REST, Endpoints probably isn't right for you.

If your API closely follows REST, have fun.

Keywords

FAQs

Package last updated on 31 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc