Skip to content

Added: Promise return type for req.session.save() function #701

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,18 @@ req.session.save(function(err) {
})
```

#### Session.save().then(callback)

You can use Promise type as return

Example
```js
await req.session.save()
.then(()=>{
// session saved
})
```

#### Session.touch()

Updates the `.maxAge` property. Typically this is
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ function session(options) {
debug('saving %s', this.id);
savedHash = hash(this);
_save.apply(this, arguments);
return this.req.sessionStore.setPromise;
}

Object.defineProperty(sess, 'reload', {
Expand Down
2 changes: 1 addition & 1 deletion session/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ defineMethod(Session.prototype, 'resetMaxAge', function resetMaxAge() {
*/

defineMethod(Session.prototype, 'save', function save(fn) {
this.req.sessionStore.set(this.id, this, fn || function(){});
this.req.sessionStore.setPromise = this.req.sessionStore.set(this.id, this, fn || function(){});
return this;
});

Expand Down