extension-serve-static

0.1.6 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i extension-serve-static

Weekly Downloads

1

Version

0.1.6

License

GPL-2.0

Last publish

Collaborators

  • tute