🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

api-media-type

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-media-type

A Node.js module exporting a map of common media type names to registered IANA media type names. Built specifically to serve the needs of Web APIs.

0.1.0
latest
npm
Version published
Weekly downloads
27
50%
Maintainers
1
Weekly downloads
 
Created
Source

api-media-type

A Node.js module exporting a map of common media type names to registered IANA media type names. Built specifically to serve the needs of Web APIs.

This module combines the fields offered by hypermedia-type and data-media-type.

Install

$ npm install api-media-type

Usage

var http = require('http');
var MediaType = require('api-media-type');

http.createServer(function(req, res) {
  res.statusCode = 200;
  res.setHeader('Content-Type', MediaType.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

See documentation for hypermedia-type and data-media-type.

License

MIT

Keywords

api

FAQs

Package last updated on 02 Feb 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