How to use the @keystonejs/session.commonSessionMiddleware function in @keystonejs/session

To help you get started, we’ve selected a few @keystonejs/session examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keystonejs / keystone / packages / keystone / lib / Keystone / index.js View on Github external
apps = [],
    distDir,
    pinoOptions,
    cors = { origin: true, credentials: true },
  } = {}) {
    const middlewares = flattenDeep([
      this.appVersion.addVersionToHttpHeaders &&
        ((req, res, next) => {
          res.set('X-Keystone-App-Version', this.appVersion.version);
          next();
        }),
      // Used by other middlewares such as authentication strategies. Important
      // to be first so the methods added to `req` are available further down
      // the request pipeline.
      // TODO: set up a session test rig (maybe by wrapping an in-memory store)
      commonSessionMiddleware({
        keystone: this,
        cookieSecret: this._cookieSecret,
        sessionStore: this._sessionStore,
        secureCookies: this._secureCookies,
        cookieMaxAge: this._cookieMaxAge,
      }),
      falsey(process.env.DISABLE_LOGGING) && require('express-pino-logger')(pinoOptions),
      cors && createCorsMiddleware(cors),
      ...(await Promise.all(
        [
          // Inject any field middlewares (eg; WYSIWIG's static assets)
          // We do this first to avoid it conflicting with any catch-all routes the
          // user may have specified
          ...this.registeredTypes,
          ...flattenDeep(
            Object.values(this.auth).map(authStrategies => Object.values(authStrategies))

@keystonejs/session

Tools to assist with setting up session management in your Keystone system.

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis

Similar packages