New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mimeware

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mimeware

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

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-83.02%
Maintainers
1
Weekly downloads
 
Created
Source

mimeware Build Status Dependency Status NPM version

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

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

Installation

npm install mimeware --save

Usage

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 © Tomas Aparicio

Keywords

FAQs

Package last updated on 28 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc