Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Mar 31, 2024 via pnpm

serve-static 1.12.3

Serve static files
Package summary
Share
4
issues
3
high severity
vulnerability
3
1
low severity
vulnerability
1
2
licenses
18
MIT
2
ISC
Package created
6 Mar 2014
Version published
17 May 2017
Maintainers
1
Total deps
20
Direct deps
4
License
MIT

Issues

4

3 high severity issues

high
Recommendation: Upgrade to version 0.5.2 or later
via: send@0.15.3
Recommendation: Upgrade to version 1.4.1 or later
via: send@0.15.3
Recommendation: Upgrade to version 2.6.9 or later
via: send@0.15.3
Collapse
Expand

1 low severity issue

low
Recommendation: Upgrade to version 2.6.9 or later
via: send@0.15.3
Collapse
Expand

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
18 Packages, Including:
debug@2.6.7
depd@1.1.2
destroy@1.0.4
ee-first@1.1.1
encodeurl@1.0.2
escape-html@1.0.3
etag@1.8.1
fresh@0.5.0
http-errors@1.6.3
mime@1.3.4
ms@2.0.0
on-finished@2.3.0
parseurl@1.3.3
range-parser@1.2.1
send@0.15.3
serve-static@1.12.3
statuses@1.3.1
statuses@1.5.0

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
inherits@2.0.3
setprototypeof@1.1.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

4
All Dependencies CSV
β“˜ This is a list of serve-static 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
encodeurl1.0.23.18 kBMIT
prod
escape-html1.0.31.87 kBMIT
prod
parseurl1.3.33.86 kBMIT
prod
send0.15.313.61 kBMIT
prod
3
1

Visualizations

Frequently Asked Questions

What does serve-static do?

The serve-static module in Node.js is a middleware used for serving static files. These files are served from a specific root directory. The file to be served is determined by the combination of req.url with the provided root directory. If the file isn't found, instead of sending a 404 response, the module will call next() to move on to the next middleware, thereby allowing for stacking and fall-backs.

How do you use serve-static?

In order to use serve-static, you first need to install it by running npm install serve-static in your terminal. Once installed, you can require it in your application like this:

var serveStatic = require('serve-static')

Afterwards, you can set up the middleware to serve files from a specific directory. For example, to serve files from a directory named public, use the code below:

// Serve up public/ftp folder
var serve = serveStatic('public/ftp', { index: ['index.html', 'index.htm'] })

Here, serve is a function, which can be used with an HTTP Server object:

var finalhandler = require('finalhandler')
var http = require('http')
var serveStatic = require('serve-static')

var serve = serveStatic('public/ftp', { index: ['index.html', 'index.htm'] })

var server = http.createServer(function onRequest (req, res) {
  serve(req, res, finalhandler(req, res))
})

server.listen(3000)

In this example, the server listens on port 3000, and files in the public/ftp directory can be accessed by browsing to http://localhost:3000. The { index: ['index.html', 'index.htm'] } option specifies that index.html or index.htm will be served when a request targets a directory.

Where are the serve-static docs?

The serve-static documentation is available in the README file on the GitHub project page. More in-depth details can be found directly on the GitHub repository for serve-static. By visiting the link, users can access comprehensive information about API usage, available options, and several code examples demonstrating how to use serve-static in various settings.