Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.use(webpackHotMiddleware(compiler, {
log: console.log,
path: '/__webpack_hmr',
heartbeat: 2000,
}));
app.use(session({
secret: 'secretClementine',
resave: false,
saveUninitialized: true,
}));
} else {
// Production Env Production Specific stuff
// - Use MongoStore instead of MemoryStore for the session
const MongoStore = connectMongo(session);
app.use(session({
secret: 'secretClementine',
resave: false,
saveUninitialized: true,
store: new MongoStore({ mongooseConnection: mongoose.connection }),
}));
// setup the logger
app.use(morgan(':status :method :response-time ms - :url'));
}
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
require('./app/config/passport')(passport);
app.use(passport.initialize());
import express from 'express';
import favicon from 'serve-favicon';
import morgan from 'morgan';
import compression from 'compression';
import bodyParser from 'body-parser';
import methodOverride from 'method-override';
import cookieParser from 'cookie-parser';
import errorHandler from 'errorhandler';
import path from 'path';
import lusca from 'lusca';
import config from './environment';
import passport from 'passport';
import session from 'express-session';
import connectMongo from 'connect-mongo';
import mongoose from 'mongoose';
var mongoStore = connectMongo(session);
module.exports = function(app) {
var env = app.get('env');
app.set('views', config.root + '/server/views');
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(compression());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(methodOverride());
app.use(cookieParser());
app.use(passport.initialize());
// Persist sessions with mongoStore / sequelizeStore
// We need to enable sessions for passport-twitter because it's an
import express from 'express';
import favicon from 'serve-favicon';
import morgan from 'morgan';
import compression from 'compression';
import bodyParser from 'body-parser';
import methodOverride from 'method-override';
import cookieParser from 'cookie-parser';
import errorHandler from 'errorhandler';
import path from 'path';
import lusca from 'lusca';
import config from './environment';
import passport from 'passport';
import session from 'express-session';
import connectMongo from 'connect-mongo';
import mongoose from 'mongoose';
var mongoStore = connectMongo(session);
module.exports = function(app) {
var env = app.get('env');
app.set('views', config.root + '/server/views');
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(compression());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(methodOverride());
app.use(cookieParser());
app.use(passport.initialize());
// Persist sessions with mongoStore / sequelizeStore
// We need to enable sessions for passport-twitter because it's an
import mongo from "connect-mongo";
import path from "path";
import flash from "connect-flash";
import compression from "compression";
import cors from "cors";
import helmet from "helmet";
import errorHandler from "errorhandler";
dotenv.config({path: "variable.env"});
import indexRouter from "./routes/index";
import authRouter from "./routes/auth";
import "./handlers/passport";
// import environmental variables from our variables.env file
const MongoStore = mongo(session);
// Create Express server
const app = express();
app.use(helmet());
// view engine setup
app.set("views", path.join(__dirname, "../views")); // this is the folder where we keep our pug files
app.set("view engine", "pug"); // we use the engine pug, mustache or EJS work great too
app.get("env") === "development" ? app.use(require("express-status-monitor")()) : "";
app.use(logger("dev"));
app.use(compression());
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.use(cors());
// serves up static files from the public folder. Anything in public/ will just be served up as the file it is
app.use(express.static(path.join(__dirname, "../public")));
import morgan from 'morgan'
import cookieParser from 'cookie-parser'
import bodyParser from 'body-parser'
import connectMongo from 'connect-mongo'
import graphQLHTTP from 'express-graphql'
import render from './middleware/render'
import bootServer from './bootstrap'
import apiApp from './api/app'
import getMongoDBUrl from './helpers/getMongoDBUri'
import middleware from './middleware'
import schema from './graphql/schema'
import { SESSION_SECRET, REQ_SIZE_LIMIT, PUBLIC_URL, PUBLIC_DIR, COOKIE_MAX_AGE } from './constants'
const debug = require('debug')('readr:init')
const MongoStore = connectMongo(session)
const app = express()
interface InitConfig {
basePath: string
}
export default function initialize(config: InitConfig) {
debug('app init')
const { basePath } = config
// locals
app.locals.basePath = basePath
app.use(session({
secret: SESSION_SECRET,
resave: true,
export default async function getRouter() {
const config = await getConfigPromise();
await getDbConnection();
const router = express.Router();
// app.use(cookieParser());
// set up session store
const MongoStore = connectMongo(expressSession);
router.use(expressSession({
secret: config.get('cookiesecret'),
// some options should be set when on GAE
secure: config.get('is_gae'),
cookie: { sameSite: true },
saveUninitialized: false,
// resave and touchAfter go together. resave specifies if the session
// info is always resaved, even if unchanged. touchAfter (as best I can
// tell) means how often to resave the session info even if nothing has
// changed (and is given in seconds)
resave: false,
// use default connection
store: new MongoStore({
mongooseConnection: mongoose.connection,
touchAfter: 24 * 3600,
}),
export default async function getRouter() {
const config = await getConfigPromise();
await getDbPromise();
const router = express.Router();
// app.use(cookieParser());
// set up session store
const MongoStore = connectMongo(expressSession);
// comments about options:
// secure: some options should be set when on GAE
// resave: resave and touchAfter go together. resave specifies if the
// session info is always resaved, even if unchanged. touchAfter (as
// best I can tell) means how often to resave the session info even if
// nothing has changed (and is given in seconds)
// store: use default connection
router.use(expressSession({
secret: config.get('cookiesecret'),
secure: config.get('is_gae'),
cookie: { sameSite: true },
saveUninitialized: false,
resave: false,
store: new MongoStore({
mongooseConnection: mongoose.connection,
touchAfter: 24 * 3600,
function connect() {
var options = {
useNewUrlParser: true
};
return mongoose.connect(appConfig.db, options);
}
const app = express();
const indexController = require('./controller/indexController');
const hubController = require('./controller/').hubController;
const authMiddleware = require('./middlewares/auth').authMiddleware;
const staticPath = path.join(__dirname, '../build/static');
const templatePath = path.join(__dirname, '../build/templates');
const MongoStore = connectMongo(session);
app.set('views', templatePath);
app.set('view engine', 'pug');
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(session({
resave: true,
saveUninitialized: true,
secret: 'bitbal',
store: new MongoStore({
url: appConfig.db,
collection: 'sessions'
bio: profile._json.bio,
avatar_url: profile.photos[0].value,
github_url: profile.profileUrl,
email: (profile.emails && profile.emails[0].value) || null,
seenWelcomeModal: false,
})
.save()
.then(result => done(null, result));
});
}));
passport.serializeUser((user, done) => done(null, user._id));
passport.deserializeUser((_id, done) => User.findOne({ _id }).then(user => done(null, user)));
const MongoStore = connectMongo(session);
app.use(session({
secret: process.env.SESSION_SECRET,
store: new MongoStore({ mongooseConnection: mongoose.connection }),
resave: true,
saveUninitialized: true,
}));
app.use(passport.initialize());
app.use(passport.session());
app.get('/login/github', passport.authenticate('github'));
app.get(
'/login/github/callback',
passport.authenticate('github', { failureRedirect: '/' }),