Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hsdk

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hsdk

An hsdk for accessing the resources on the L&W API

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42
increased by950%
Maintainers
1
Weekly downloads
 
Created
Source

hsdk

hsdk stands for HATEOAS Software Development Kit. This library reads from a specified 'application metadata' endpoint and generates an HTTP HATEOAS API client.

Version Tests Stability Dependencies

using

import hsdk from "hsdk"

hsdk({protocol: "http", host: "hsdkjs.getsandbox.com", root: "v1/resources"})
  .then((client) => client("v1Accounts").list())
  .then((value) => console.log(value))

jsonapi-home

Much like json-home, a fantastic spec by @mnot, jsonapi-home is an attempt to allow clients to build themselves.

Using the example above, we need a HTTP server running on hsdkjs.getsandbox.com that responds to http requests to GET /v1/resources.

Here is a sample CURL-based request (an example of what hsdk does under the hood):

curl -X "GET" "http://hsdkjs.getsandbox.com/v1/resources" \
     -H "Accept: application/vnd.api+json"

Each resource MUST have the following properties:

  • intent: The human name for this result, example: list, show, create, destroy, update
  • namespace: The groupings this resource is under, can be anything
  • description: A short description for the resource
  • method: The HTTP verb used
  • href: A RFC 6570 URL template that the client can use directly
  • mediatype: The preferred mediatype for this endpoint
  • allowed (FUTURE): An allowed list of fields
  • query (FUTURE): An allowed list of query parameter names

That response will look like this:

HTTP/1.1 200 OK
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Date: Mon, 28 Nov 2016 19:50:32 GMT

{
  "links": {
    "self": "http://hsdkjs.getsandbox.com/v1/resources",
    "next": "http://hsdkjs.getsandbox.com/v1/resources?page[offset]=2",
    "last": "http://hsdkjs.getsandbox.com/v1/resources?page[offset]=10"
  },
  "data": [
    {
      "id": "v1-accounts-list",
      "type": "resources",
      "attributes": {
        "intent": "list",
        "namespace": "v1/accounts",
        "description": "List accounts.",
        "method": "GET",
        "href": "http://hsdkjs.getsandbox.com/v2/accounts",
        "query": {
          "filter": true,
          "sort": true
        },
        "mediatype": "application/vnd.api+json"
      },
      "links": {
        "self": "http://hsdkjs.getsandbox.com/v1/resources/v1-accounts-list"
      }
    },
    {
      "id": "v1-accounts-show",
      "type": "resources",
      "attributes": {
        "intent": "show",
        "namespace": "v1/accounts",
        "description": "Show an individual account.",
        "method": "GET",
        "href": "http://hsdkjs.getsandbox.com/v1/accounts/{id}",
        "query": {
          "fields": true
        },
        "mediatype": "application/vnd.api+json"
      },
      "links": {
        "self": "http://hsdkjs.getsandbox.com/v1/resources/v1-accounts-show"
      }
    },
    {
      "id": "v1-accounts-update",
      "type": "resources",
      "attributes": {
        "intent": "update",
        "namespace": "v1/accounts",
        "description": "Update an individual account.",
        "method": "PATCH",
        "href": "http://hsdkjs.getsandbox.com/v1/accounts/{id}",
        "allowed": [
          [
            "data",
            "attributes",
            "age"
          ]
        ],
        "mediatype": "application/vnd.api+json"
      },
      "links": {
        "self": "http://hsdkjs.getsandbox.com/v1/resources/v1-accounts-update"
      }
    }
  ]
}

Keywords

FAQs

Package last updated on 28 Nov 2016

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