# node libraries
expressSession = (require 'express-session')
RedisStore = (require 'connect-redis')(expressSession)

module.exports = (app) ->
  session =
  secret: 'keyboard cat'
  store: new RedisStore
    host: 'redis'
    port: 6379
  cookie:
    httpOnly: true
    sameSite: 'strict'
  proxy: true
  resave: true
  saveUninitialized: true

  if app.get 'env' == 'production'
    app.set 'trust proxy', 1
    session.cookie.secure = true

  expressSession session
