Socket
Socket
Sign inDemoInstall

hypermedia-type

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    hypermedia-type

A Node.js module exporting a map of common hypermedia names to registered IANA media type names.


Version published
Maintainers
1
Install size
3.99 kB
Created

Readme

Source

hypermedia-type

A Node.js module for finding IANA registered names for common hypermedia types.

See also:

Install

$ npm install hypermedia-type

Usage

var http = require('http');
var HypermediaType = require('hypermedia-type');

http.createServer(function(req, res) {
  res.statusCode = 200;
  res.setHeader('Content-Type', HypermediaType.SIREN);

  var entity = {
    class: [ 'order' ],
    properties: { 
        orderNumber: 42, 
        itemCount: 3,
        status: 'pending'
    },
    links: [
      { rel: [ 'self' ], href: 'http://api.x.io/orders/42' },
      { rel: [ 'next' ], href: 'http://api.x.io/orders/43' }
    ]
  };

  res.end(JSON.stringify(entity));
}).listen(1337);

Supported Media Types

  • HypermediaType.ATOM => application/atom+xml
  • HypermediaType.COLLECTION => application/vnd.collection+json
  • HypermediaType.HAL => application/hal+json
  • HypermediaType.HAL_XML => application/hal+xml
  • HypermediaType.HTML => text/html
  • HypermediaType.JSON_LD => application/ld+json
  • HypermediaType.SIREN => application/vnd.siren+json
  • HypermediaType.XHTML => application/xhtml+xml

License

MIT

Keywords

FAQs

Last updated on 26 Jul 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc