Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { db, User } from './graphql/connectors';
import parseXml from './utils/parseXml';
import startCron from './utils/cron';
import { setupPassport, buildHelmetOptions } from './utils/auth';
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev });
const handle = app.getRequestHandler()
const server = express();
setupPassport();
startCron();
const schema = makeExecutableSchema({ typeDefs, resolvers });
const SequelizeStore = storeBuilder(session.Store);
if (process.env.PROXY === 'true') {
server.set('trust proxy', 1); // trust first proxy
}
// Middlewares
server.disable('x-powered-by');
server.use(helmet(buildHelmetOptions()));
server.use(bodyParser.json());
server.use(session({
store: new SequelizeStore({ db }),
secret: 'dogs',
name: 'session',
cookie: {
secure: process.env.HTTPS === 'true',
expires: new Date(Date.now() + 48 * 60 * 60 * 1000) // 48 hours
app.use((req, res, next) => {
if (req.hostname === 'lunch.labzero.com') {
res.redirect(301, generateUrl(req, config.bsHost, path));
} else {
next();
}
});
//
// Session / Flash
// -----------------------------------------------------------------------------
if (__DEV__) {
app.enable('trust proxy');
}
const SequelizeStore = connectSessionSequelize(session.Store);
app.use(session({
cookie: {
domain: config.domain,
secure: process.env.NODE_ENV === 'production'
},
saveUninitialized: false,
secret: config.auth.session.secret,
store: new SequelizeStore({
db: sequelize
}),
resave: false,
proxy: true
}));
app.use(flash());