Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', (compilation) => {
compilation.plugin('html-webpack-plugin-after-emit', (data, cb) => {
hotMiddleware.publish({ action: 'reload' })
cb()
})
})
app.use(hotMiddleware)
}
app.use(logger('dev'))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cookieParser());
app.use(session({
store: new FileStore(),
secret: 'express-dwb',
resave: false,
saveUninitialized: false,
cookie: { secure: false }
}))
app.use(express.static('dist'))
app.use('/', routes);
mongoose.connect(config.mongoUrl);
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', () => {
app.listen(port, config.host, (err) => {
//----------------------------------------------------------------------------------------------------------------------
// Build the express app
var app = express();
// Basic request logging
app.use(routeUtils.requestLogger(logger));
// Basic error logging
app.use(routeUtils.errorLogger(logger));
// Auth support
app.use(cookieParser());
app.use(bodyParser.json());
app.use(session({
secret: config.secret || 'nosecret',
key: config.key || 'sid',
resave: false,
rolling: true,
// maxAge = 12hrs
cookie: { maxAge: 1000 * 60 * 60 * 12},
saveUninitialized: false,
store: new FileStore({ path: './server/db/sessions' })
//saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
// Set up our authentication support
localAuth.initialize(app);
import session from 'express-session'
import body_parser from 'body-parser'
import configuration from '../configuration'
global.configuration = configuration
import json_rpc from './json rpc'
import utility from './api/utility'
import log from './log'
json_rpc.add('utility', utility)
const web = express()
web.use(session
({
secret: 'beast breaker',
resave: false,
saveUninitialized: false,
cookie: { maxAge: 60000 }
}))
web.use(body_parser.json())
function api()
{
return new Promise((resolve, reject) =>
{
web.post('/', (http_request, http_response) =>
{
// const version = http_request.params[0]
//
// Register Node.js middleware
// -----------------------------------------------------------------------------
app.use(express.static(path.resolve(__dirname, 'public')));
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cors());
app.use(fileUpload());
//
// Authentication
// -----------------------------------------------------------------------------
app.use(session({ secret: 'grant' }));
app.use(
grant({
...config.grant,
}),
);
if (__DEV__) {
app.enable('trust proxy');
}
app.post('/token', async (req, res) => {
const authResponse = await auth(req.body);
res.json({ Response: authResponse });
});
//
import fs from "fs-path";
// Used for transpiling
import webpack from "webpack";
import config from "../webpack.config";
import dbUtils from "./db.js";
const port = 8000;
const app = express();
const compiler = webpack(config);
dotenv.config();
// gzip files
app.use(compression());
app.use(session({secret: process.env.SESSION_SECRET}));
app.use(bodyParser.json());
app.use(bodyParser({extended: true}));
app.use(cors());
// Use Webpack middleware
app.use(require("webpack-dev-middleware")(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.get("/*", (req, res) => {
res.sendFile(path.join(__dirname, "../src/index.html"));
});
app.post("/api/upload", (req, res) => {
res.writeHead(200, {"Content-Type": "application/json"});
import "./passport";
import routes from "./routes";
import formatTime from "./utils/formatTime";
const CookieStore = MongoStore(session);
const app = express();
app.set("view engine", "pug");
app.use(express.static(path.join(__dirname, "static")));
app.use(logger("dev"));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(
session({
secret: process.env.COOKIE_SECRET,
resave: true,
saveUninitialized: true,
store: new CookieStore({ mongooseConnection: mongoose.connection })
})
);
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
app.use((req, res, next) => {
res.locals.siteName = "WeTube";
res.locals.user = req.user || null;
res.locals.routes = routes;
res.locals.helpers = {
app.useSession = (url, getArgs) => {
app.set('trust proxy', 2);
if (!getArgs) {
getArgs = url;
url = null;
}
const args = getArgs(session);
if (url) app.use(url, session(args));
else app.use(session(args));
};
app.useStatic = url => express.static(url);
app.useSession = (url, getArgs) => {
app.set('trust proxy', 2);
if (!getArgs) {
getArgs = url;
url = null;
}
const args = getArgs(session);
if (url) app.use(url, session(args));
else app.use(session(args));
};
app.useStatic = url => express.static(url);
export default app => {
app.use(cookieParser());
app.use(
session({
secret: app.get('env') === 'production' ? uniqueID() : 'harvey&lola',
store: new MongoStore({
mongooseConnection: mongoose.connection,
}),
resave: false,
saveUninitialized: false,
})
);
app.use(passport.initialize());
app.use(passport.session());
app.post(
'/api/login',
validation.validateRequest(
Joi.object({
export default function renderer({
clientStats,
server,
sessionStore,
promises,
}: any) {
const app = express.Router();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded(config.bodyParser.urlencoded));
app.use(cookieParser(config.cookieParser as any));
app.use(session({ store: sessionStore, ...config.session }));
app.use(csurf(config.csurf));
app.use(serverTiming());
app.use(favicon(config.favicon));
app.use(useragent.express());
if (!__DEVELOPMENT__) {
const assetsHandler = new AssetsHandler(clientStats.assets);
app.use(
clientStats.publicPath,
assetsHandler.handleUrl.bind(assetsHandler),
);
}
config.assets.forEach(asset => {
app.use(asset.mount, express.static(asset.path));
});