extension-serve-static
v0.1.6
Published
Serve static files based on file name extensions
Downloads
24
Readme
extension-serve-static
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)