Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
call-bind | 1.0.2 | 5.24 kB | MIT | prod | |
connect | 1.9.2 | 75.28 kB | UNKNOWN | prod | 2221 |
formidable | 1.0.17 | 12.04 kB | UNKNOWN | prod | 11 |
function-bind | 1.1.1 | 6.15 kB | MIT | prod | |
get-intrinsic | 1.2.1 | 11.49 kB | MIT | prod | |
has-proto | 1.0.1 | 3.3 kB | MIT | prod | |
has-symbols | 1.0.3 | 6.9 kB | MIT | prod | |
has | 1.0.3 | 1.52 kB | MIT | prod | |
mime | 3.0.0 | 18.25 kB | MIT | prod | |
object-inspect | 1.12.3 | 25.31 kB | MIT | prod | |
qs | 6.11.2 | 52 kB | BSD-3-Clause | prod | |
side-channel | 1.0.4 | 5.51 kB | MIT | prod |
Connect is an extensible HTTP server framework for Node.JS that uses plugins known as middleware to handle requests. This high-performance middleware framework glues together different middleware components, thus providing a simple framework to handle various HTTP requests. Moreover, it offers a high degree of flexibility when it comes to adding new functionalities, enhancing the overall extensibility of your application.
To use Connect, you need to install it using npm. You can do this by running:
$ npm install connect
After installation, you need to create an app and "use" middleware. Here is an example of how to set up a basic server using Connect:
var connect = require('connect');
var http = require('http');
var app = connect();
// respond to all requests
app.use(function(req, res){
res.end('Hello from Connect!\n');
});
//create Node.js http server and listen on port
http.createServer(app).listen(3000);
You can also add various plugins for outgoing response compression, session state storage, body parsing, and many more. These plugins are invoked via the 'use' method. For instance:
var compression = require('compression');
app.use(compression());
You can also mount middleware for basic routing:
app.use('/foo', function fooMiddleware(req, res, next) {
// req.url starts with "/foo"
next();
});
Finally, to start the app listening for requests, use the listen() method:
var server = app.listen(port);
The Connect documentation, which covers the detailed API and usage instructions, can be found in the README.md file on the Connect GitHub repository. Here you find information about how to add a chain of middleware, use routes, create a server, and further information about supported middleware and libraries. For any additional queries, consider looking at the 'Issues' section on the repository, or the list of contributors who might be able to provide additional context or advice.