micro-session
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

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

const session, { MemoryStore } = require('micro-session')

const getSession = session({
  store: new MemoryStore(),
  secret: 'keyboard cat'
})

module.exports = async (req, res) => {
  let session = await getSession(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

Readme

Keywords

Package Sidebar

Install

npm i micro-session

Weekly Downloads

6

Version

2.0.1

License

MIT

Unpacked Size

33 kB

Total Files

7

Last publish

Collaborators

  • meyer9