{"id":13726941,"url":"https://github.com/tinyhttp/mime-types","last_synced_at":"2025-07-23T21:09:39.189Z","repository":{"id":52290887,"uuid":"279132381","full_name":"tinyhttp/mime-types","owner":"tinyhttp","description":"`mime-types` rewrite in TypeScript compiled to ESM","archived":false,"fork":false,"pushed_at":"2021-10-23T09:36:14.000Z","size":91,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T10:00:32.913Z","etag":null,"topics":["esm","node-js","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinyhttp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-12T19:19:02.000Z","updated_at":"2023-09-28T21:09:20.000Z","dependencies_parsed_at":"2022-09-07T05:12:14.164Z","dependency_job_id":null,"html_url":"https://github.com/tinyhttp/mime-types","commit_stats":null,"previous_names":["tinyhttp/mime-types","talentlessguy/es-mime-types"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tinyhttp/mime-types","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fmime-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fmime-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fmime-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fmime-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinyhttp","download_url":"https://codeload.github.com/tinyhttp/mime-types/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fmime-types/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266748725,"owners_count":23978271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esm","node-js","nodejs"],"created_at":"2024-08-03T01:03:32.348Z","updated_at":"2025-07-23T21:09:39.153Z","avatar_url":"https://github.com/tinyhttp.png","language":"TypeScript","readme":"# es-mime-types\n\n![Top language][top-lang-image]\n![Vulnerabilities][snyk-image]\n[![Version][npm-v-image]][npm-url]\n[![Node Version][node-version-image]][node-version-url]\n![Last commit][last-commit-image]\n\n\u003e [`mime-types`](https://github.com/jshttp/mime-types) rewrite in TypeScript compiled to ESM\n\nThe ultimate javascript content-type utility.\n\nSimilar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except:\n\n- **No fallbacks.** Instead of naively returning the first available type,\n  `mime-types` simply returns `false`, so do\n  `const type = mime.lookup('unrecognized') || 'application/octet-stream'`.\n- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.\n- No `.define()` functionality\n- Bug fixes for `.lookup(path)`\n\nOtherwise, the API is compatible with `mime` 1.x.\n\n## Install\n\n```sh\npnpm i es-mime-types\n```\n\n## Adding Types\n\nAll mime types are based on [mime-db](https://www.npmjs.com/package/mime-db),\nso open a PR there if you'd like to add mime types.\n\n## API\n\n```ts\nimport { lookup, contentType, extension, charset, types } from 'es-mime-types'\n```\n\nAll functions return `false` if input is invalid or not found.\n\n### `lookup(path)`\n\nLookup the content-type associated with a file.\n\n```ts\nlookup('json') // 'application/json'\nlookup('.md') // 'text/markdown'\nlookup('file.html') // 'text/html'\nlookup('folder/file.js') // 'application/javascript'\nlookup('folder/.htaccess') // false\nlookup('cats') // false\n```\n\n### `contentType(type)`\n\nCreate a full content-type header given a content-type or extension.\nWhen given an extension, `lookup` is used to get the matching\ncontent-type, otherwise the given content-type is used. Then if the\ncontent-type does not already have a `charset` parameter, `charset`\nis used to get the default charset and add to the returned content-type.\n\n```ts\ncontentType('markdown') // 'text/x-markdown; charset=utf-8'\ncontentType('file.json') // 'application/json; charset=utf-8'\ncontentType('text/html') // 'text/html; charset=utf-8'\ncontentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1'\n\n// from a full path\ncontentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'\n```\n\n### `extension(type)`\n\nGet the default extension for a content-type.\n\n```ts\nextension('application/octet-stream') // 'bin'\n```\n\n### `charset(type)`\n\nLookup the implied default charset of a content-type.\n\n```ts\ncharset('text/markdown') // 'UTF-8'\n```\n\n### `types[extension]`\n\nA map of extensions by content-type.\n\n## License\n\nMIT © [v1rtl](https://v1rtl.site)\n\n[node-version-image]: https://img.shields.io/node/v/es-mime-types.svg?style=flat-square\n[node-version-url]: https://nodejs.org\n[top-lang-image]: https://img.shields.io/github/languages/top/talentlessguy/es-mime-types.svg?style=flat-square\n[snyk-image]: https://img.shields.io/snyk/vulnerabilities/npm/es-mime-types.svg?style=flat-square\n[npm-v-image]: https://img.shields.io/npm/v/es-mime-types.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/es-mime-types\n[last-commit-image]: https://img.shields.io/github/last-commit/talentlessguy/es-mime-types.svg?style=flat-square\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinyhttp%2Fmime-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinyhttp%2Fmime-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinyhttp%2Fmime-types/lists"}