Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Express = require('express');
const path = require('path');
const Promise = require('bluebird');
const SenecaWeb = require('seneca-web');
const _ = require('lodash');
const bodyParser = require('body-parser');
const auth = require('http-auth');
const passport = require('passport');
const Router = Express.Router;
const context = new Router();
const basicAuth = auth.basic({
file: config.Dashboard.htpasswd
});
passport.use(auth.passport(basicAuth));
const senecaWebConfig = {
context,
adapter: require('seneca-web-adapter-express'), // eslint-disable-line
options: { parseBody: false },
};
const app = Express();
app.use(bodyParser.json());
app.use(context);
app.use(Express.static(path.resolve(`${__dirname}/../public`)) );
app.set('view engine', 'pug');
app.set('views', path.resolve(`${__dirname}/../views`));
// redirect http to https
const bodyParser = require('body-parser');
const config = require('config');
const elasticsearch = require('elasticsearch');
const Express = require('express');
const passport = require('passport');
const path = require('path');
const Router = Express.Router;
const _ = require('lodash');
const { makeElasticsearchOptions } = require('../util/elasticOptions.js');
const context = new Router();
const basicAuth = auth.basic({
file: config.ElasticsearchAPI.htpasswd
});
passport.use(auth.passport(basicAuth));
const app = Express();
app.use(bodyParser.json());
app.use(context);
// redirect http to https
if (process.env.NODE_ENV === "production") {
app.enable('trust proxy');
app.use(function(req, res, next) {
if (req.headers['x-forwarded-proto'] && req.headers['x-forwarded-proto'].toLowerCase() === 'http') {
return res.redirect('https://' + req.headers.host + req.url);
}
return next();
});
}