1.0.3 • Published 6 years ago

hapi-sessions v1.0.3

Weekly downloads
13
License
-
Repository
github
Last release
6 years ago

hapi-sessions

Sessions plugin for hapi. It relies on catbox, so you can use whatever storage for them that catbox provides.

Example

await server.register([
    {
        plugin: require(`./hapi-sessions`),
        options: {
            expiresIn: 3 * 24 * 60 * 60 * 1000,
            password: ``, // 32 symbol password should be passed
            cache: `cache-name`
        }
    }
]);

Options

  • expiresIn TTL for the session cookie and the cache record.
  • password Passowrd for cookie encryption.
  • cache Cache name created within server.cache.
  • isSecure, isHttpOnly the same as in server.state options.

API

  • await request.session.get() – gets the session data, stored in cache.
  • await request.session.set(value) – sets the session data.
  • await request.session.addOrChange(value) – use only when the session data stored as an object. It merges passed object with stored in session one.
  • request.sessionsCache – a link to a catbox policy with all the sessions. You can take the session id from request.state.session.

The plugin has been made by a total rookie for personal purposes. Any critics are welcome.

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago