Coder Social home page Coder Social logo

dunglas / ketting Goto Github PK

View Code? Open in Web Editor NEW

This project forked from badgateway/ketting

0.0 2.0 0.0 2.36 MB

Ketting is a Hypermedia client for javascript

Home Page: https://www.npmjs.com/package/ketting

License: MIT License

JavaScript 0.73% Makefile 0.50% TypeScript 98.77%

ketting's Introduction

Ketting ๐Ÿ”— - A hypermedia client for javascript

  • Go to the Wiki for full documentation.

Introduction

The Ketting library is a generic REST client with Hypermedia features.

The library will work with any JSON-based HTTP API, but it gets superpowers when using it with formats that have support for links, including:

And it even works with HTML links, and HTTP Link Headers.

Ketting is designed to both work in the browser and in Node.js. Additionally, it has [react bindings][ketting-react] that will make it work in a way that's familiar to Apollo-Client users.

Example

const ketting = new Ketting('https://api.example.org/');

// Follow a link with rel="author". This could be a HTML5 `<link>`, a
// HAL `_links` or a HTTP `Link:`.
const author = await ketting.follow('author');

// Grab the current state
const authorState = await author.get();

// Change the firstName property of the object. Note that this assumes JSON.
authorState.data.firstName = 'Evert';

// Save the new state
await author.put(authorState);

Docs

Notable Features

Ketting is a library that sits on top of Fetch API to provide a RESTful interface and make it easier to follow REST best practices more strictly.

It provides some useful abstractions that make it easier to work with true hypermedia / HATEOAS servers. It currently parses many hypermedia formats and has a deep understanding of links and embedded resources. There's also support for parsing and following links from HTML documents, and it understands the HTTP Link: header.

It also has support for 'fetch middlewares', which is used to implement OAuth2 support, but also opens the door to development of other plugins.

Using this library it becomes very easy to follow links from a single bookmark, and discover resources and features on the server.

Supported formats:

  • HAL
  • Siren - Including support for actions.
  • HTML - Can automatically follow <link> and <a> element with rel= attributes, and submit HTML <form>s.
  • HTTP Link header - automatically registers as links regardless of format.
  • JSON:API - Understands the links object and registers collection members as item relationships.
  • application/problem+json - Will extract useful information from the standard problem object and embed them in exception objects.

Other features:

Read further on the Wiki

ketting's People

Contributors

bolt04 avatar dependabot[bot] avatar evert avatar gabesullice avatar germanp avatar greenkeeper[bot] avatar jameswomack avatar juhangsin avatar kay-is avatar madsmadsen avatar mhum avatar mihok avatar ravinggenius avatar reda-alaoui avatar simistern avatar wiese avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.