Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import express from 'express';
import session from 'express-session';
import cookieParser from 'cookie-parser';
import path from 'path';
import bodyParser from 'body-parser';
import methodOverride from 'method-override';
import https from 'https';
import fs from 'fs';
import sslRootCas from 'ssl-root-cas';
import helmet from 'helmet';
import express_enforces_ssl from 'express-enforces-ssl';
import pg from 'pg';
import ConnectPg from 'connect-pg-simple';
var pgSession = ConnectPg(session);
import csurf from 'csurf';
import signInRoutes from './middleware/routes/sign-in-routes.js';
import signOutRoutes from './middleware/routes/sign-out-routes.js';
import signUpRoutes from './middleware/routes/sign-up-routes.js';
import userRoutes from './middleware/routes/user-routes.js';
import passport from './middleware/auth/passport.js';
import error from './middleware/error/error.js';
var server = express();
// ======== *** VIEWS AND TEMPLATES ***
//Set port
import db from './db';
import tileserver from './tiles/tileserver';
import apiServer from './api/api';
import frontendRoute from './frontendRoute';
// create server
const server = express();
// disable header
server.disable('x-powered-by');
// serve static files
server.use(express.static(process.env.RAZZLE_PUBLIC_DIR));
// handle user sessions
const pgSession = pgConnect(session);
const sess: any = { // TODO: remove any
name: 'cl.session',
store: new pgSession({
pgPromise: db,
tableName: 'user_sessions'
}),
secret: process.env.APP_COOKIE_SECRET,
saveUninitialized: false,
resave: false,
cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 } // 30 days
};
if (server.get('env') === 'production') {
// trust first proxy
server.set('trust proxy', 1)
// serve secure cookies
sess.cookie.secure = true
import session from 'express-session';
import pg from 'pg';
import connectPostgres from 'connect-pg-simple';
import { db } from '../sequelize/constants';
const PGStore = connectPostgres(session);
export default () =>
new PGStore(
{
pg,
conString: db
}
);
function getSessionStore(session: Session) {
const pgSession = connectPgSimple(session);
return new pgSession({ pool });
}