Skip to content

alexander3um/hapi-sessions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

Way too simple sessions for Hapi.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published