Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace var keywords with const #1134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@
Connect is an extensible HTTP server framework for [node](http://nodejs.org) using "plugins" known as _middleware_.

```js
var connect = require('connect');
var http = require('http');
const connect = require('connect');
const http = require('http');

var app = connect();
const app = connect();

// gzip/deflate outgoing responses
var compression = require('compression');
const compression = require('compression');
app.use(compression());

// store session state in browser cookie
var cookieSession = require('cookie-session');
const cookieSession = require('cookie-session');
app.use(cookieSession({
keys: ['secret1', 'secret2']
}));

// parse urlencoded request bodies into req.body
var bodyParser = require('body-parser');
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: false}));

// respond to all requests
app.use(function(req, res){
app.use(function (req, res) {
res.end('Hello from Connect!\n');
});

Expand All @@ -56,7 +56,7 @@ The main component is a Connect "app". This will store all the middleware
added and is, itself, a function.

```js
var app = connect();
const app = connect();
```

### Use middleware
Expand Down Expand Up @@ -121,14 +121,14 @@ is a convenience to start a HTTP server (and is identical to the `http.Server`'s
method in the version of Node.js you are running).

```js
var server = app.listen(port);
const server = app.listen(port);
```

The app itself is really just a function with three arguments, so it can also be handed
to `.createServer()` in Node.js.

```js
var server = http.createServer(app);
const server = http.createServer(app);
```

## Middleware
Expand Down Expand Up @@ -183,10 +183,10 @@ a new app when called.

```js
// require module
var connect = require('connect')
const connect = require('connect');

// create app
var app = connect()
const app = connect();
```

### app(req, res[, next])
Expand Down Expand Up @@ -220,7 +220,7 @@ app.use(function (req, res, next) {
// req is the Node.js http request object
// res is the Node.js http response object
// next is a function to call to invoke the next middleware
})
});
```

In addition to a plan function, the `fn` argument can also be a Node.js HTTP server
Expand All @@ -238,7 +238,7 @@ app.use('/foo', function (req, res, next) {
// req is the Node.js http request object
// res is the Node.js http response object
// next is a function to call to invoke the next middleware
})
});
```

In addition to a plan function, the `fn` argument can also be a Node.js HTTP server
Expand Down