data-media-type

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

npm install data-media-type
4 downloads in the last month

data-media-type

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

See also:

Install

$ npm install data-media-type

Usage

var http = require('http');
var DataMediaType = require('data-media-type');

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

  var body = {
    hello: 'world'
  };

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

Supported Media Types

  • DataMediaType.FORM_URLENCODED => application/x-www-form-urlencoded
  • DataMediaType.JSON => application/json
  • DataMediaType.MULTIPART_FORM_DATA => multipart/form-data
  • DataMediaType.OCTET_STREAM => application/octet-stream
  • DataMediaType.TEXT_PLAIN => text/plain
  • DataMediaType.TEXT_XML => text/xml
  • DataMediaType.XML => application/xml

License

MIT

npm loves you