connect-ottoman

connect-ottoman provides Couchbase Ottoman session storage for Express. Requires Ottoman >= 2.0.0-beta.2

Usage no npm install needed!

<script type="module">
  import connectOttoman from 'https://cdn.skypack.dev/connect-ottoman';
</script>

README

connect-ottoman provides Ottoman session storage for Express. Requires Ottoman >= 2.0.0-beta.

Installation

npm:

npm install connect-ottoman express-session express

Yarn:

yarn add connect-ottoman express-session express

API

import connectOttoman from 'connect-ottoman'
import express from 'express'
import session, { Store } from 'express-session'
import { Ottoman } from 'ottoman'

  ; (async () => {
    const OttomanStore = connectOttoman(session)
    const client = new Ottoman()
    client.connect({
      connectionString: 'localhost:8091',
      bucketName: 'example',
      username: 'example',
      password: 'someSecret'
    })
    const store = new OttomanStore({ client })


    const createApp = (store: Store) => {
      const app = express()
      app.use(express.json())
      app.use(session({
        ...{
          secret: 'example',
          name: 'sid',
          cookie: {
            maxAge: 180000,
            secure: false,
            sameSite: true
          },
          rolling: true,
          resave: false,
          saveUninitialized: false
        },
        store
      }))
      return app
    }
    const app = createApp(store)

    app.listen(3000, () => console.log(`http://localhost:3000`))
  })()

document expiration collection must be created with ttl to avail document expiration`.