next-session
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "next-session", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Simple session middleware for Next.js API Routes", | ||
"main": "index.js", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib/" | ||
], | ||
"scripts": { | ||
"lint": "eslint ./ -c .eslintrc --ext js --ignore-path .gitignore --fix", | ||
"build": "babel src -d lib", | ||
"lint": "eslint src -c .eslintrc --ext js --ignore-path .gitignore --fix", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -21,2 +25,5 @@ }, | ||
"devDependencies": { | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"eslint": "^5.16.0", | ||
@@ -23,0 +30,0 @@ "eslint-config-airbnb-base": "^13.2.0", |
@@ -14,6 +14,23 @@ # next-session | ||
```javascript | ||
// Using Node.js require | ||
const session = require('next-session'); | ||
// Using ES6 import | ||
import session from 'next-session'; | ||
const handler = (req, res) => { | ||
if (req.session.views) { | ||
// On later visits, increase # of views by one on every request | ||
req.session.views += 1; | ||
} else { | ||
// On first visit, set # of views to 1 | ||
req.session.views = 1; | ||
} | ||
res.send(`In this session, you have visited this page ${req.session.views} time(s).`) | ||
}; | ||
// wrap handler with session middleware and include options | ||
export default session(handler, { | ||
name: 'sid', | ||
cookies: { | ||
secure: true, | ||
maxAge: 1209600000, | ||
}, | ||
}); | ||
``` | ||
@@ -20,0 +37,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19979
298
105
6
7
1