• Stars
    star
    1,083
  • Rank 42,742 (Top 0.9 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Media Type Database

mime-db

NPM Version NPM Downloads Node.js Version Build Status Coverage Status

This is a large database of mime types and information about them. It consists of a single, public JSON file and does not include any logic, allowing it to remain as un-opinionated as possible with an API. It aggregates data from the following sources:

Installation

npm install mime-db

Database Download

If you're crazy enough to use this in the browser, you can just grab the JSON file using jsDelivr. It is recommended to replace master with a release tag as the JSON format may change in the future.

https://cdn.jsdelivr.net/gh/jshttp/mime-db@master/db.json

Usage

var db = require('mime-db')

// grab data on .js files
var data = db['application/javascript']

Data Structure

The JSON file is a map lookup for lowercased mime types. Each mime type has the following properties:

  • .source - where the mime type is defined. If not set, it's probably a custom media type.
  • .extensions[] - known extensions associated with this mime type.
  • .compressible - whether a file of this type can be gzipped.
  • .charset - the default charset associated with this type, if any.

If unknown, every property could be undefined.

Contributing

The primary way to contribute to this database is by updating the data in one of the upstream sources. The database is updated from the upstreams periodically and will pull in any changes.

Registering Media Types

The best way to get new media types included in this library is to register them with the IANA. The community registration procedure is outlined in RFC 6838 section 5. Types registered with the IANA are automatically pulled into this library.

Direct Inclusion

If that is not possible / feasible, they can be added directly here as a "custom" type. To do this, it is required to have a primary source that definitively lists the media type. If an extension is going to be listed as associateed with this media type, the source must definitively link the media type and extension as well.

To edit the database, only make PRs against src/custom-types.json or src/custom-suffix.json.

The src/custom-types.json file is a JSON object with the MIME type as the keys and the values being an object with the following keys:

  • compressible - leave out if you don't know, otherwise true/false to indicate whether the data represented by the type is typically compressible.
  • extensions - include an array of file extensions that are associated with the type.
  • notes - human-readable notes about the type, typically what the type is.
  • sources - include an array of URLs of where the MIME type and the associated extensions are sourced from. This needs to be a primary source; links to type aggregating sites and Wikipedia are not acceptable.

To update the build, run npm run build.

More Repositories

1

http-errors

Create HTTP Errors
JavaScript
1,489
star
2

mime-types

The ultimate javascript content-type utility.
JavaScript
1,311
star
3

cookie

HTTP server cookie parsing and serialization
JavaScript
1,303
star
4

basic-auth

Generic basic auth Authorization header field parser
JavaScript
704
star
5

on-finished

Execute a callback when a request closes, finishes, or errors
JavaScript
389
star
6

negotiator

An HTTP content negotiator for Node.js
JavaScript
307
star
7

statuses

HTTP status utility
JavaScript
269
star
8

accepts

Higher-level content negotiation
JavaScript
252
star
9

etag

Create simple HTTP ETags
JavaScript
251
star
10

type-is

Infer the content-type of a request.
JavaScript
226
star
11

content-disposition

Create and parse HTTP Content-Disposition header
JavaScript
220
star
12

methods

HTTP verbs that node supports
JavaScript
177
star
13

fresh

HTTP request freshness testing
JavaScript
159
star
14

on-headers

Execute a listener when a response is about to write headers.
JavaScript
154
star
15

http-assert

assert with status codes
JavaScript
151
star
16

proxy-addr

Determine address of proxied request
JavaScript
132
star
17

content-type

Create and parse HTTP Content-Type header
JavaScript
130
star
18

style-guide

jshttp style guide
JavaScript
108
star
19

compressible

Compressible Content-Type / mime checking.
JavaScript
98
star
20

range-parser

Range header field parser
JavaScript
90
star
21

vary

Manipulate the HTTP Vary header
JavaScript
61
star
22

forwarded

Parse HTTP X-Forwarded-For header
JavaScript
56
star
23

media-typer

Simple RFC 6838 media type parser and formatter
JavaScript
54
star
24

jshttp.github.io

HTML
47
star
25

spdy-push

SPDY Push helper - will by replaced by http-push
JavaScript
29
star
26

http-push

14
star
27

http-utils

Low-level HTTP parsing/formatting utilities
JavaScript
14
star
28

.github

1
star