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 8, 2024 via pnpm

finalhandler 1.2.0

Node.js final http responder
Package summary
Share
0
issues
1
license
10
MIT
Package created
6 Jun 2014
Version published
23 Mar 2022
Maintainers
1
Total deps
10
Direct deps
7
License
MIT

Issues

0
This package has no issues

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
10 Packages, Including:
debug@2.6.9
ee-first@1.1.1
encodeurl@1.0.2
escape-html@1.0.3
finalhandler@1.2.0
ms@2.0.0
on-finished@2.4.1
parseurl@1.3.3
statuses@2.0.1
unpipe@1.0.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

7
All Dependencies CSV
β“˜ This is a list of finalhandler 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
debug2.6.916.13 kBMIT
prod
encodeurl1.0.23.18 kBMIT
prod
escape-html1.0.31.87 kBMIT
prod
on-finished2.4.14.93 kBMIT
prod
parseurl1.3.33.86 kBMIT
prod
statuses2.0.14.57 kBMIT
prod
unpipe1.0.02.05 kBMIT
prod

Visualizations

Frequently Asked Questions

What does finalhandler do?

Finalhandler is a Node.js function designed to carry out the final step in responding to an HTTP request. It works by returning a function to be invoked as the final step for the respective request and response. This makes the flow of handling requests highly manageable as the final step ensures either a 404 response is written out, or, in the case of any errors, an error response will be dispatched appropriately.

How do you use finalhandler?

You'll first need to install the finalhandler module using the NPM install command in your terminal. Simply run npm install finalhandler. Once installed, you can require it in your program as var finalhandler = require('finalhandler').

A basic usage example would be the following:

var finalhandler = require('finalhandler')
var http = require('http')

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

server.listen(3000)

In this case, the server will always return a 404 since no routes are handled. In a more practical scenario, you may want to return a file as the response, for instance, an HTML file:

var finalhandler = require('finalhandler')
var fs = require('fs')
var http = require('http')

var server = http.createServer(function (req, res) {
  var done = finalhandler(req, res)

  fs.readFile('index.html', function (err, buf) {
    if (err) return done(err)
    res.setHeader('Content-Type', 'text/html')
    res.end(buf)
  })
})

server.listen(3000)

Here, we read index.html and send its content as the response. If any error occurs, done(err) is called.

Where are the finalhandler docs?

The documentation for finalhandler can be found in its NPM package page and the GitHub repository. Links to these locations can be found in the readme. The readme contains explanatory details about the API, options it accepts, and usage examples. It presents clear instructions on installation, function syntax, options that you can pass into the main function, and example code snippets.