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39.0.\n * Original file: /npm/sqlpad@3.1.0/app.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const fs = require('fs');\nconst path = require('path');\nconst express = require('express');\nconst helmet = require('helmet');\nconst session = require('express-session');\nconst FileStore = require('session-file-store')(session);\nconst config = require('./lib/config');\n\nconst baseUrl = config.get('baseUrl');\nconst googleClientId = config.get('googleClientId');\nconst googleClientSecret = config.get('googleClientSecret');\nconst publicUrl = config.get('publicUrl');\nconst dbPath = config.get('dbPath');\nconst debug = config.get('debug');\nconst cookieName = config.get('cookieName');\nconst cookieSecret = config.get('cookieSecret');\nconst sessionMinutes = config.get('sessionMinutes');\n\nconst samlEntryPoint = config.get('samlEntryPoint');\nconst samlIssuer = config.get('samlIssuer');\nconst samlCallbackUrl = config.get('samlCallbackUrl');\nconst samlCert = config.get('samlCert');\nconst samlAuthContext = config.get('samlAuthContext');\n\n/*  Express setup\n============================================================================= */\nconst bodyParser = require('body-parser');\nconst favicon = require('serve-favicon');\nconst morgan = require('morgan');\nconst passport = require('passport');\nconst errorhandler = require('errorhandler');\n\nconst app = express();\n\n// Default helmet protections, minus frameguard (becaue of sqlpad iframe embed), adding referrerPolicy\napp.use(helmet.dnsPrefetchControl());\napp.use(helmet.hidePoweredBy());\napp.use(helmet.hsts({}));\napp.use(helmet.ieNoOpen());\napp.use(helmet.noSniff());\napp.use(helmet.xssFilter());\napp.use(helmet.referrerPolicy({ policy: 'same-origin' }));\n\napp.set('env', debug ? 'development' : 'production');\n\nif (debug) {\n  app.use(errorhandler());\n}\napp.use(favicon(path.join(__dirname, '/public/favicon.ico')));\napp.use(bodyParser.json());\napp.use(\n  bodyParser.urlencoded({\n    extended: true\n  })\n);\n\napp.use(\n  session({\n    store: new FileStore({\n      path: path.join(dbPath, '/sessions')\n    }),\n    saveUninitialized: false,\n    resave: true,\n    rolling: true,\n    cookie: { maxAge: 1000 * 60 * sessionMinutes },\n    secret: cookieSecret,\n    name: cookieName\n  })\n);\n\napp.use(passport.initialize());\napp.use(passport.session());\napp.use(baseUrl, express.static(path.join(__dirname, 'public')));\nif (debug) {\n  app.use(morgan('dev'));\n}\n\n/*  Passport setup\n============================================================================= */\nrequire('./middleware/passport.js');\n\n/*  Routes\n============================================================================= */\nconst routers = [\n  require('./routes/drivers.js'),\n  require('./routes/users.js'),\n  require('./routes/forgot-password.js'),\n  require('./routes/password-reset.js'),\n  require('./routes/connections.js'),\n  require('./routes/test-connection.js'),\n  require('./routes/queries.js'),\n  require('./routes/query-result.js'),\n  require('./routes/download-results.js'), // streams result download to browser\n  require('./routes/schema-info.js'),\n  require('./routes/tags.js'),\n  require('./routes/format-sql.js'),\n  require('./routes/signup-signin-signout.js')\n];\n\nif (googleClientId && googleClientSecret && publicUrl) {\n  if (debug) {\n    console.log('Enabling Google authentication Strategy.');\n  }\n  routers.push(require('./routes/oauth.js'));\n}\n\nif (\n  samlEntryPoint &&\n  samlIssuer &&\n  samlCallbackUrl &&\n  samlCert &&\n  samlAuthContext\n) {\n  if (debug) {\n    console.log('Enabling SAML authentication Strategy.');\n  }\n  routers.push(require('./routes/saml.js'));\n}\n\n// Add all core routes to the baseUrl except for the */api/app route\nrouters.forEach(function(router) {\n  app.use(baseUrl, router);\n});\n\n// Add '*/api/app' route last and without baseUrl\napp.use(require('./routes/app.js'));\n\n// For any missing api route, return a 404\n// NOTE - this cannot be a general catch-all because it might be a valid non-api route from a front-end perspective\napp.use(baseUrl + '/api/', function(req, res) {\n  console.log('reached catch all api route');\n  res.sendStatus(404);\n});\n\n// Anything else should render the client-side app\n// Client-side routing will take care of things from here\n// Because index.html will be served via static plugin,\n// we need to rename it to something else and switch out the URLs to consider the baseUrl\nconst indexPath = path.join(__dirname, 'public/index.html');\nconst indexTemplatePath = path.join(__dirname, 'public/index-template.html');\n\nif (fs.existsSync(indexPath)) {\n  fs.renameSync(indexPath, indexTemplatePath);\n}\n\nif (fs.existsSync(indexTemplatePath)) {\n  const html = fs.readFileSync(indexTemplatePath, 'utf8');\n  const baseUrlHtml = html\n    .replace(/=\"\\/stylesheets/g, `=\"${baseUrl}/stylesheets`)\n    .replace(/=\"\\/javascripts/g, `=\"${baseUrl}/javascripts`)\n    .replace(/=\"\\/images/g, `=\"${baseUrl}/images`)\n    .replace(/=\"\\/fonts/g, `=\"${baseUrl}/fonts`)\n    .replace(/=\"\\/static/g, `=\"${baseUrl}/static`);\n  app.use((req, res) => res.send(baseUrlHtml));\n} else {\n  console.error('\\nNO FRONT END TEMPLATE DETECTED');\n  console.error('If not running in dev mode please report this issue.\\n');\n}\n\nmodule.exports = app;\n"]}