Skip to content

Repository files navigation

micro-session

micro-session is a session manager for Zeit.co's micro framework. Heavily based on express-session.

Installation

$ npm install micro-session
# or
$ yarn add micro-session

Example Usage

constsession,{ MemoryStore }=require('micro-session')constgetSession=session({store: newMemoryStore(),secret: 'keyboard cat'})module.exports=async(req,res)=>{letsession=awaitgetSession(req,res)if(!session.test){session.test=1}else{session.test+=1}return{t: session.test}}

Note that sessions are automatically stored if needed after res.end is called. All session stores that support express-session should also support micro-session.

Options are the same as express-session where applicable. session API is also the same as express-session.

License

MIT

About

Session middleware for micro

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages