<commit_before>// Licensed under the Apache 2.0 License. See footer for details.

var express = require("express"),
  http = require("http"),
  path = require("path"),
  cloudant = require("cloudant"),
  dotenv = require("dotenv"),
  validator = require("validator"),
  bodyParser = require("body-parser"),
  passport = require("passport"),
  cfenv = require("cfenv"),
  cookieParser = require("cookie-parser"),
  IbmIdStrategy = require("passport-ibmid-oauth2").Strategy,
  expressSession = require("express-session"),
  memoryStore = new expressSession.MemoryStore(),
  RedisStore = require("connect-redis")(expressSession),
  _ = require("underscore"),
  crypto = require("crypto"),
  csv = require("express-csv"), // jshint ignore:line
  hbs = require("hbs"),
  forceSSL = require("express-force-ssl");


dotenv.load();

var appEnv = cfenv.getAppEnv();

var app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());

app.enable("trust proxy");

var sessionStore;

if (!appEnv.isLocal) {
  var redisService = appEnv.getService(new RegExp(".*" + "deployment-tracker-redis" +".*", "i"));

  sessionStore = new RedisStore({
    host: redisService.credentials.hostname,
    port: redisService.credentials.port,
    pass: redisService.credentials.password
  });
}
else {
  sessionStore = memoryStore;
}

//in future PR switch to redis or cloudant as a session store
app.use(expressSession({ secret: process.env.SECRET || "blah",
  store: sessionStore,
  resave: false,
  saveUninitialized: false<commit_msg>updated to use secure cookies<commit_after>// Licensed under the Apache 2.0 License. See footer for details.

var express = require("express"),
  http = require("http"),
  path = require("path"),
  cloudant = require("cloudant"),
  dotenv = require("dotenv"),
  validator = require("validator"),
  bodyParser = require("body-parser"),
  passport = require("passport"),
  cfenv = require("cfenv"),
  cookieParser = require("cookie-parser"),
  IbmIdStrategy = require("passport-ibmid-oauth2").Strategy,
  expressSession = require("express-session"),
  memoryStore = new expressSession.MemoryStore(),
  RedisStore = require("connect-redis")(expressSession),
  _ = require("underscore"),
  crypto = require("crypto"),
  csv = require("express-csv"), // jshint ignore:line
  hbs = require("hbs"),
  forceSSL = require("express-force-ssl");


dotenv.load();

var appEnv = cfenv.getAppEnv();

var app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());

app.enable("trust proxy");

var sessionStore;

if (!appEnv.isLocal) {
  var redisService = appEnv.getService(new RegExp(".*" + "deployment-tracker-redis" +".*", "i"));

  sessionStore = new RedisStore({
    host: redisService.credentials.hostname,
    port: redisService.credentials.port,
    pass: redisService.credentials.password
  });
}
else {
  sessionStore = memoryStore;
}

//in future PR switch to redis or cloudant as a session store
app.use(expressSession({ secret: process.env.SECRET || "blah",
  store: sessionStore,
  resave: false,
  saveUninitialized: false
  secure: true
{'fraction_non_alphanumeric': 0.15726441853135834, 'fraction_numerical': 0.0018909549322407816, 'mean_word_length': 5.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7066113', 'n_tokens_mistral': 998, 'n_tokens_neox': 991, 'n_words': 225}