A Node.js module for finding IANA registered names for common hypermedia types.
See also:
data-media-type
- contains common data media types (JSON, XML, x-form-urlencoded, etc.)api-media-type
- combines data-media-type and hypermedia-type
$ npm install hypermedia-type
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);
HypermediaType.ATOM
=> application/atom+xmlHypermediaType.COLLECTION
=> application/vnd.collection+jsonHypermediaType.HAL
=> application/hal+jsonHypermediaType.HAL_XML
=> application/hal+xmlHypermediaType.HTML
=> text/htmlHypermediaType.JSON_LD
=> application/ld+jsonHypermediaType.SIREN
=> application/vnd.siren+jsonHypermediaType.XHTML
=> application/xhtml+xml
MIT