"use strict";

const hapi = require('hapi');
const fs = require('fs');
const path = require('path');

const inert = require('inert');
const vision = require('vision');
const handlebars = require('handlebars');
const CookieAuth = require('hapi-auth-cookie');
const routes = require('./routes/index.js');
const deployStatus = process.env.NODE_ENV === 'PRODUCTION';

const server = new hapi.Server();

server.connection ({
  port: process.env.PORT || 9443,
  tls: {
    key: fs.readFileSync(path.join(__dirname, '../keys_tls/key.pem')),
    cert: fs.readFileSync(path.join(__dirname, '../keys_tls/cert.pem'))
  }
});

server.register([inert, vision, CookieAuth], (err) => {
  if (err) throw err;
  server.views({
    engines: {
      html: handlebars
    },
    path: 'src/views',
    layoutPath: 'src/views/layout',
    layout: 'default',
    partialsPath: 'src/views/partials'
  });
  server.auth.strategy('base', 'cookie', options);
  server.route(routes);
});

const options = {
    password: 'D8M8#7PqdkRbb}/=NhvG#(B&/tA6v:unC2S',
    cookie: 'yoti-cookie',
    isSecure: deployStatus,
    ttl: 24 * 60 * 60 * 1000
};

module.exports = server;

@@ -302,28 +302,28 @@
 ;%0Aconst 
-deployStatus
+isProduction
  = proce
@@ -396,27 +396,26 @@
 );%0A%0A
-server.
+let 
 conn
-ec
+Op
 tion
+s =
  
-(
 %7B%0A  
@@ -446,18 +446,86 @@
 %7C 9443,%0A
-  
+%7D%0A%0Aserver.connection(connOptions);%0A%0Aif (isProduction) %7B%0A  connOptions.
 tls: %7B%0A 
@@ -670,19 +670,17 @@
 '))%0A  %7D%0A
+
 %7D
-);
 %0A%0Aserver
@@ -1136,20 +1136,20 @@
 re: 
-deployStatus
+isProduction
 ,%0A  

Make tls configs dependent on environment