Socket
Socket
Sign inDemoInstall

extension-serve-static

Package Overview
Dependencies
16
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    extension-serve-static

Serve static files based on file name extensions


Version published
Weekly downloads
5
increased by150%
Maintainers
1
Install size
281 kB
Created
Weekly downloads
 

Readme

Source

extension-serve-static

NPM Version NPM Downloads Linux Build Windows Build Test Coverage

serve-static based on file name extensions

based on serve-static

All in serve-static documentation is working here. But extension-serve-static add one mandatory parameter:

staticExtensions

staticExtensions is a white list of extensions names for serve, this allows something like this:

var connect = require('connect')
var extensionServeStatic = require('extension-serve-static')

var app = connect()

// Serve up all folders for images
app.use(extensionServeStatic('/', {
    extensions: ['html', 'htm'], 
    index: 'index.html', 
    staticExtensions: ['', 'html', 'htm', 'png', 'jpg', 'jpeg', 'gif']
})

// Listen
app.listen(3000)

default extensions

For use the serve-static extensions parameter you must include de empty string ('') in the staticExtension list (as you see in the example).

mime types

extension-serve-static also search the extension in the mime types. If you need to add a non standard extension you can add it in the mime field

var connect = require('connect')
var extensionServeStatic = require('extension-serve-static')

var mime = extensionServeStatic.mime;

mime.types.specialimage = 'image/special';

var app = connect()

// Serve up all folders for images
app.use(extensionServeStatic('/', {
    extensions: ['html', 'htm'], 
    index: 'index.html', 
    staticExtensions: ['', 'html', 'htm', 'png', 'jpg', 'jpeg', 'gif', 'specialimage']
})

// Listen
app.listen(3000)

License

GPL-2.0

FAQs

Last updated on 31 Jan 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc