Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.configure( function () {
app.use(express.bodyParser({ uploadDir: settings.uploadPath }));
app.set('port', process.env.PORT || settings.port);
app.use(express.logger('dev'));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
app.use(express.cookieParser());
app.use(express.methodOverride());
app.engine('.jade', require('jade').__express);
app.use(app.router);
// Static URLS
app.use('/uploads', express.directory(settings.uploadPath));
app.use('/vendor', express.static(settings.vendorPath));
app.use('/units', express.static(settings.unitsPath));
app.use('/integrations', express.static(settings.integrationsPath));
app.use('/fine-uploader', express.static(settings.sourcePath));
})
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
var screenshotsPath = path.join(__dirname, '..', '..', 'test', 'e2etesting', 'screenshots');
var refScreenshotsPath = path.join(__dirname, '..', '..', 'test', 'e2etesting', 'screenshots-tmp');
var screenShotsURL = '/screenshots';
var refScreenShotsURL = '/reference-screenshots';
app.use(screenShotsURL, express.directory(screenshotsPath));
app.use(screenShotsURL, express.static(screenshotsPath));
app.use(refScreenShotsURL, express.directory(refScreenshotsPath));
app.use(refScreenShotsURL, express.static(refScreenshotsPath));
app.use(express.errorHandler());
app.get('/', function(req,res){
var compare = {};
var refPngs = glob(screenshotsPath+'/**/*.png',function(err,pngs){
for(var i=0; i
app.configure(function () {
var cwd = process.cwd();
console.log(cwd);
// used to parse JSON object given in the body request
app.use(express.bodyParser());
app.use(express.static(cwd));
app.use(express.directory(cwd));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
function servePathAtPort(path, port) {
var app = express();
app.use(express.static(path)); // before directory to allow index.html to work
app.use(express.directory(path));
app.listen(port);
console.log('serving ' + path + ' at ' + port);
}
process.nextTick(function() {
cb.apply(this, args);
});
}).bind(this);
}
var webserver;
if (program.serve) {
webserver = express();
webserver.all('*', function(req, res, next) {
var clientAddress = req.headers['x-forwarded-for'];
if (clientAddress) logger.info(util.format('Request from %s: %s %s', clientAddress, req.method, req.originalUrl));
else logger.info(util.format('Request: %s %s', req.method, req.originalUrl));
return next();
});
if (program.directory) webserver.use(express.directory(process.cwd()));
webserver.use(express.static(process.cwd()));
}
bindWithServer(program.server, nextTick(function(socket, address) {
if (program.ratelimit) require('ratelimit')(socket, program.ratelimit * 1024, true);
copyToClipboard(address);
logger.info('Secure connection established with tunnel server.');
logger.info(util.format('Serving content through: %s', address));
delete socket._httpMessage; // not properly cleaned up after UPGRADE/Connect in node.js core
var mpx = new Multiplexer(socket);
mpx.listen(function(error, channel) {
if (program.proxy) {
var proxyHost = '127.0.0.1';
var proxyPort = program.proxy;
if (program.proxy.indexOf(':') != -1) {
var hostParts = program.proxy.split(':');
app.use(express.compress());
app.use(express.favicon(config.web.favicon));
app.use(express.logger(config.web.loglevel));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser());
// Redirect non-https load balanced clients to https
app.use(redirectHttps);
// /ping for load balancer health checking
app.get('/ping', function (req, res, next) { res.send('pong'); });
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use('/feeds', express.directory(path.join(__dirname, 'feeds')));
app.use('/feeds', express.static(path.join(__dirname, 'feeds')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
logger.info('Running in Development Mode.');
}
//register REST services
notificationServices.registerNotificationServices(app);
pgServices.registerPostgresServices(app);
dataVerificationServices.registerDataVerificationServices(app);
authServices.registerAuthServices(app);
centralizationServices.registerCentralizationServices(app);
earlyVoteServices.registerEarlyVoteServices(app);
app.use(app.router);
//We use LESS.css as a CSS preprocessor, this middleware automatically compiles LESS into CSS on demand
app.use(require('less-middleware')({ src: __dirname + '/public' }));
//The QuickThumb module provides resizing of images on demand,
//this helps with memory usage on mobile devices by allowing them to request custom-sized images
app.use('/content', quickThumb.static(__dirname + '/public/content'))
app.use("/marker", markerMagick.static(__dirname + '/public/marker-cache'));
//Serves up static files on disk.
app.use(express.static(path.join(__dirname, 'public')));
//
app.use(express.directory(path.join(__dirname, 'public')));
// The very last layer catches any errors and renders it to the web.
app.use(express.errorHandler());
});
app.set('view options', {layout: false});
app.configure('development', function ()
{
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
app.use(express.logger());
});
// Static handlers for client-side JS and game assessts, etc.
app.use(rootPath + '/js/node_modules', express.static(__dirname + '/../../node_modules'));
app.use(rootPath + '/js/common', express.static(__dirname + '/../common'));
app.use(rootPath + '/js/client', express.static(__dirname + '/../client'));
app.use(rootPath + '/js', express.static(__dirname));
app.use(rootPath + '/static', express.static(__dirname + '/../static'));
app.use(rootPath + '/static', express.directory(__dirname + '/../static', {icons:true}));
app.use(rootPath + '/output', express.static(outputPath));
app.use(rootPath + '/output', express.directory(outputPath, {icons:true}));
// Dynamic handlers for index template -- require a trailing slash so client-side relative paths work correctly.
app.get(new RegExp('^' + rootPath + '$'), function (req, res)
{
res.redirect(rootPath + '/');
});
app.get(new RegExp('^' + rootPath + '/(:?index\\.html)?$'), function (req, res)
{
res.render(__dirname + '/templates/example.ejs', {
playerID: (req.session && req.session.playerID) || ''
});
});
// The REST API handler.
app.use(rootPath + '/api', restapi(gc));
// web.js
var express = require("express");
var logfmt = require("logfmt");
var httpProxy = require('http-proxy');
var app = express();
var port = process.env.PORT || 5000;
app.use(logfmt.requestLogger());
app.use(express.static(__dirname + '/dist'));
app.use('/', express.directory('/dist'));
var http = require('http'),
httpProxy = require('http-proxy');
//
// Create your proxy server and set the target in the options.
//
httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(port);
// Static handlers for client-side JS and game assets, etc.
app.use(rootPath + '/js/node_modules', express.static(resolveRelativePath('../../node_modules', __dirname)));
app.use(rootPath + '/js/common', express.static(resolveRelativePath('../common', __dirname)));
app.use(rootPath + '/js/client', express.static(resolveRelativePath('../client', __dirname)));
app.use(rootPath + '/js', express.static(resolveRelativePath('clientjs', __dirname)));
app.use(rootPath + '/static', express.static(resolveRelativePath('../static', __dirname)));
app.use(rootPath + '/static', express.directory(resolveRelativePath('../static', __dirname), {icons:true}));
app.use(rootPath + '/output', express.static(config.outputPath));
app.use(rootPath + '/output', express.directory(config.outputPath, {icons:true}));
app.use(rootPath + '/css', express.static(resolveRelativePath('css', __dirname)));
// These are the MATHia fluency tasks. On the production server, these are served directly by nginx instead of going through the node webapp. We have these static handlers so dev environment can run without the nginx reverse proxy.
app.use(rootPath + '/fluency/data', express.static(config.dataPath));
app.use(rootPath + '/fluency/data', express.directory(config.dataPath, {icons:true}));
// Cache Flash resources for 10 seconds.
app.use(rootPath + '/fluency/games', express.static(config.cliFlashPath, {maxAge: 10000}));
app.use(rootPath + '/fluency/games', express.directory(config.cliFlashPath, {icons:true}));
// Middleware to load student or instructor data before processing requests.
app.use(function (req, res, next)
{
if (req.session && req.session.instructorID)
{
model.Instructor.find(req.session.instructorID).on('success', function (instructor)
{
req.instructor = instructor;
next();
});
}