Miming
A very small library for parsing and formatting various different mime types in node.js.
Note: Miming does not deal with content negotiation, you should use another library such as negotiator for that.
Miming supports the following built in mime types:
application/json
application/ld+json
text/html
application/xhtml+xml
multipart/form-data
application/x-www-form-urlencoded
Installation
Via npm:
npm install miming
Usage
Creating a collection
Create a Collection of MimeTypes that you'd like to handle in your application. Specify the types in order of precedence.
var Miming = ; var collection = 'HTML' 'JSON' 'FormURLEncoded' 'MultipartFormData'; var mime = collection;mimeshouldbean; consoleshould;
Adding a type to a collection
collection;// orcollection;// orcollection;// orcollection;
Processing requests
Here's a tiny application which parses requests in various formats, translates them to JSON, and echos them back to the client.
var http = Negotiator = Miming = collection = ; collection;collection;collection; http;console;
License
MIT, see LICENSE.md.