Skip to content

Commit 5c33972

Browse files
gabeiodougwilson
authored andcommitted
changes to standard code style
fixes externally defined functions adds .eslintignore adds eslint to package.json and a script adds npm run-script lint to travis tests Signed-off-by: Gabriel D <[email protected]>
1 parent 4d25340 commit 5c33972

File tree

13 files changed

+612
-539
lines changed

13 files changed

+612
-539
lines changed

.eslintrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
root: true
2+
extends: standard
23
rules:
34
eol-last: error
45
eqeqeq: ["error", "always", { "null": "ignore" }]

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ $ npm install express-session
1717

1818
## API
1919

20+
<!-- eslint-disable no-unused-vars -->
21+
2022
```js
2123
var session = require('express-session')
2224
```
@@ -127,6 +129,9 @@ have your node.js behind a proxy and are using `secure: true`, you need to set
127129
"trust proxy" in express:
128130

129131
```js
132+
var express = require('express')
133+
var session = require('express-session')
134+
130135
var app = express()
131136
app.set('trust proxy', 1) // trust first proxy
132137
app.use(session({
@@ -141,6 +146,9 @@ For using secure cookies in production, but allowing for testing in development,
141146
the following is an example of enabling this setup based on `NODE_ENV` in express:
142147

143148
```js
149+
var express = require('express')
150+
var session = require('express-session')
151+
144152
var app = express()
145153
var sess = {
146154
secret: 'keyboard cat',
@@ -175,7 +183,7 @@ The default value is a function which uses the `uid-safe` library to generate ID
175183

176184
```js
177185
app.use(session({
178-
genid: function(req) {
186+
genid: function (req) {
179187
return genuuid() // use UUIDs for session IDs
180188
},
181189
secret: 'keyboard cat'
@@ -297,10 +305,10 @@ are typically fine. For example below is a user-specific view counter:
297305

298306
```js
299307
// Use the session middleware
300-
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))
308+
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 } }))
301309

302310
// Access the session as req.session
303-
app.get('/', function(req, res, next) {
311+
app.get('/', function (req, res, next) {
304312
if (req.session.views) {
305313
req.session.views++
306314
res.setHeader('Content-Type', 'text/html')
@@ -321,7 +329,7 @@ a new SID and `Session` instance will be initialized at `req.session`
321329
and the `callback` will be invoked.
322330

323331
```js
324-
req.session.regenerate(function(err) {
332+
req.session.regenerate(function (err) {
325333
// will have a new session here
326334
})
327335
```
@@ -332,7 +340,7 @@ Destroys the session and will unset the `req.session` property.
332340
Once complete, the `callback` will be invoked.
333341

334342
```js
335-
req.session.destroy(function(err) {
343+
req.session.destroy(function (err) {
336344
// cannot access session here
337345
})
338346
```
@@ -343,7 +351,7 @@ Reloads the session data from the store and re-populates the
343351
`req.session` object. Once complete, the `callback` will be invoked.
344352

345353
```js
346-
req.session.reload(function(err) {
354+
req.session.reload(function (err) {
347355
// session updated
348356
})
349357
```
@@ -363,7 +371,7 @@ There are some cases where it is useful to call this method, for example,
363371
redirects, long-lived requests or in WebSockets.
364372

365373
```js
366-
req.session.save(function(err) {
374+
req.session.save(function (err) {
367375
// session saved
368376
})
369377
```

0 commit comments

Comments
 (0)