# mimeware

> Framework agnostic HTTP middleware to infer the proper MIME content type response header

Latest version **0.1.2** (published 2015-01-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install mimeware
pnpm add mimeware
yarn add mimeware
bun add mimeware
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2015-01-28 |
| First published | 2015-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Tomas Aparicio |
| Maintainers | h2non |
| Keywords | middleware, mime, content, type, mimetype, types, text, response, express, connect |

## Links

- npm: https://www.npmjs.com/package/mimeware
- Repository: https://github.com/h2non/mimeware
- Issues: https://github.com/h2non/mimeware/issues
- npm.io page: https://npm.io/package/mimeware

## Dependencies (2)

- [mime](https://npm.io/package/mime.md) ^1.2.11
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^3.0.0

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 0.1.2 (latest) — 2015-01-28
- 0.1.1 — 2015-01-28
- 0.1.0 — 2015-01-27

## README

# mimeware [![Build Status](https://api.travis-ci.org/h2non/mimeware.svg?branch=master)][travis] [![Dependency Status](https://gemnasium.com/h2non/mimeware.svg)][gemnasium] [![NPM version](https://badge.fury.io/js/mimeware.svg)][npm]

Node.js/io.js HTTP server middleware to infer and define the proper MIME content type as response header

It is web framework agnostic and works properly in Connect, Express, Restify, Sails... among others
which implements the standard connect-based middleware interface: `use(function (req, res, next) { ... })`

It includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community. It uses [node-mime](https://github.com/broofa/node-mime)

It was implemented specially for older Express/Connect versions 
which has no smart support for content type discovering

## Installation

```bash
npm install mimeware --save
```

## Usage

```js
var express = require('express')
var mimeware = require('mimeware')
var app = express()

app.use(mimeware({ defaultType: 'text/html' }))

app.get('/hello', function (req, res, next) {
  // respond with default type: text/html
  res.send('Hello World!')
})

app.get('/hello.json', function (req, res, next) {
  // respond with type: application/json
  res.json({ say: 'Hello World!' })
})

app.get('/hello.xml', function (req, res, next) {
  // respond with type: text/xml
  res.send('<say>Hello World!</say>')
})
```

### Options

#### defaultType
Type: `string` Type: `text/html`

Define the default MIME type to use if cannot infer it

#### ignore
Type: `array<string|regex>`

An array of regex or string-like path patterns to ignore

#### defaultCharset
Type: `string` Default: `utf-8`

Define the default charset encoding type if cannot infer one.

#### charset
Type: `boolean` Default: `true`

Define the proper encoding charset if required

## License

[MIT](http://opensource.org/licenses/MIT) © Tomas Aparicio

[travis]: http://travis-ci.org/h2non/mimeware
[gemnasium]: https://gemnasium.com/h2non/mimeware
[npm]: http://npmjs.org/package/mimeware

---
_Source: https://npm.io/package/mimeware · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
