Socket
Socket
Sign inDemoInstall

micro-session

Package Overview
Dependencies
5
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    micro-session

Session manager for micro


Version published
Weekly downloads
8
Maintainers
1
Install size
80.6 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 02 Nov 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc