NODEJS

Using Connect

Article by:
Date Published:
Last Modified:

Overview

Connect is a middleware framework for node. It contains a body parser, cookie manager, session management, static file server, query string parser, favicon server, and more.

The Express extension uses the Connect extension to provide some of it’s functionality.

Installation

To install Connect, you can use NPM (node package manager) with the following command:

1
$ npm install connect

Static File Server

One of Connects useful features is the ability to easily create a static file server. The most basic file server can be achieved with the following code:

1
2
connect()
    .use(connect.static(__dirname + '/public'))

__dirname is a special variable which represents the current directory the code file is in.


Authors

Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Tags

    comments powered by Disqus