🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

serve-content

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serve-content

Serve static files based on file name extensions

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
56
-61.38%
Maintainers
1
Weekly downloads
 
Created
Source

serve-content

serve-content based on file name extensions and serving jade and stylus files

npm-version downloads linux windows coverage security qa-control

language: English also available in: Spanish

based on serve-static

All in serve-static documentation is working here. But serve-content add some mandatory parameters to indicate which are the allowed extensions:

allowedExts

allowedExts is a white list of extensions names for serve.

allowAllExts

allowAllExts is a boolean. True means that all extensions are allowed. It can be used with excludeExts.

excludeExts

allowedExts is a black list with ignorings extensions.

example

var connect = require('connect')
var extensionServeStatic = require('serve-content')

var app = connect()

// Serve up all folders for images
app.use(serveContent('/', {
    extensions: ['html', 'htm'],
    index: 'index.html',
    allowedExts: ['', '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

serve-content 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('serve-content')

var mime = extensionServeStatic.mime;

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

var app = connect()

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

// Listen
app.listen(3000)

License

MIT

FAQs

Package last updated on 29 Jun 2026

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