Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// extend the default configuration
self.config = config;
var app = Connect.call();
// log requests
app.use( Connect.logger("short") );
// set access types in request object
app.use(Accept);
// parse cookies
app.use( Connect.cookieParser() );
// compress responses to GZip/Deflate
app.use( Connect.compress() );
// there will be 3 main middlewares
// page server - servers rendered or cached pages
// api server - gives access to puch template & content API (/api)
// editor - loads the pages with editing capablities (/editor)
app.use( PageServer.setup(self.config) );
app.listen(self.config.server.port, self.config.server.host);
console.log("Running Punch server on %s:%s", self.config.server.host, self.config.server.port);
}
};
})
.use('/jest/blog/feed.xml', (req, res) => {
res.end(
fs.readFileSync(path.join(FILE_SERVE_ROOT, 'jest/blog/feed.xml')) + ''
);
})
.use('/jest/blog/atom.xml', (req, res) => {
res.end(
fs.readFileSync(path.join(FILE_SERVE_ROOT, 'jest/blog/atom.xml')) + ''
);
})
.use(reactMiddleware.provide(buildOptions))
.use(connect['static'](FILE_SERVE_ROOT))
// .use(connect.favicon(path.join(FILE_SERVE_ROOT, 'elements', 'favicon', 'favicon.ico')))
.use(connect.logger())
.use(connect.compress())
.use(connect.errorHandler());
const portToUse = port || 8080;
const server = http.createServer(app);
server.listen(portToUse);
console.log('Open http://localhost:' + portToUse + '/jest/index.html');
module.exports = server;
exports.start = function (config, callback) {
// project's www directory location
var static_dir = path.resolve(config.project_dir, 'www');
// Defines a new ConnectJS app
var app = connect(
connect.logger(loggers.dev('www')),
connect.compress(),
connect.static(static_dir)
);
var host = config.host,
port = config.www_server.port;
return http.createServer(app).listen(port, host, utils.announce(
'WWW started: http://' + host + ':' + port,
callback
));
};
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var util = require('util'),
colors = require('colors'),
http = require('http'),
connect = require('connect'),
httpProxy = require('../../lib/http-proxy');
//
// Basic Connect App
//
connect.createServer(
connect.compress({
// Pass to connect.compress() the options
// that you need, just for show the example
// we use threshold to 1
threshold: 1
}),
function (req, res) {
proxy.web(req, res);
}
).listen(8012);
//
// Basic Http Proxy Server
//
var proxy = httpProxy.createProxyServer({
target: 'http://localhost:9012'
});
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var util = require('util'),
colors = require('colors'),
http = require('http'),
connect = require('connect')
httpProxy = require('../../lib/http-proxy');
//
// Basic Connect App
//
connect.createServer(
connect.compress({
// Pass to connect.compress() the options
// that you need, just for show the example
// we use threshold to 1
threshold: 1
}),
function (req, res) {
proxy.web(req, res);
}
).listen(8012);
//
// Basic Http Proxy Server
//
var proxy = httpProxy.createProxyServer({
target: 'http://localhost:9012'
});
var LocalStrategy = require('passport-local').Strategy;
// Connect to the MongoDB server.
mongoose.connect(config.mongodb_server);
// Set up the app server.
var app = express();
// all environments
app.set('port', config.port);
app.set('views', __dirname + '/views');
app.set('view engine', 'dot');
app.engine('dot', doT.__express);
app.use(express.logger('dev'));
app.use(connect.compress());
app.use(stylus.middleware(__dirname + '/public'));
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieSession({
secret: config.sessionSecret,
maxAge: new Date(Date.now() + 14*24*3600*1000)
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(express.csrf());
app.use(app.router);
// development only
if ('development' == app.get('env')) {
Server.prototype.start = function(port) {
var that = this;
// Prefix all hosts with the port number
var hosts = {};
_.each(this.hosts_, function(target, host) {
hosts[host + ':' + port] = target;
});
this.hosts_ = hosts;
var app = connect()
.use(connect.logger(this.logger_))
.use(connect.compress())
.use(function(req, res) {
that.serve_(req, res);
});
http.createServer(app).listen(port);
};
serverRender: 'serverRender' in argv ?
argv.serverRender === 'true': defaults.serverRender,
dev: argv.dev === 'true'
};
if (!isServer) {
reactMiddleware.compute(buildOptions)(argv.computeForPath, function(str) {
process.stdout.write(str);
});
} else {
var app = connect()
.use(reactMiddleware.provide(buildOptions))
.use(connect['static'](FILE_SERVE_ROOT))
.use(connect.favicon(path.join(FILE_SERVE_ROOT, 'elements', 'favicon', 'favicon.ico')))
.use(connect.logger())
.use(connect.compress())
.use(connect.errorHandler());
var portToUse = port || 8080;
http.createServer(app).listen(portToUse);
console.log('Open http://localhost:' + portToUse + '/index.html');
}
readyCallback
) {
var app = connect()
.use(loadRawBody)
.use(openStackFrameInEditor)
.use(getDevToolsLauncher(options))
.use(statusPageMiddleware)
.use(getFlowTypeCheckMiddleware(options))
.use(getAppMiddleware(options));
options.projectRoots.forEach(function(root) {
app.use(connect.static(root));
});
app.use(connect.logger())
.use(connect.compress())
.use(connect.errorHandler());
return http.createServer(app).listen(options.port, '::', readyCallback);
}
app.configure('production', function(){
app.use(connect.compress());
app.use(require('less-middleware')({ src: __dirname + '/dist' }));
app.use(express.static(path.join(__dirname, 'dist'), { maxAge: oneYear }));
});