How to use the connect.compress function in connect

To help you get started, we’ve selected a few connect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github laktek / punch / lib / server.js View on Github external
// 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);
	}
};
github facebook / jest / website / server / server.js View on Github external
})
  .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;
github hoodiehq / hoodie / lib / servers / www.js View on Github external
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
    ));
};
github http-party / node-http-proxy / examples / middleware / gzip-middleware.js View on Github external
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'
});
github No9 / harmon / node_modules / http-proxy / examples / middleware / gzip-middleware.js View on Github external
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'
});
github kig / message / app.js View on Github external
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')) {
github ernestoalejo / gulp-ondemand-server / index.js View on Github external
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);
};
github facebookarchive / react-page / server.js View on Github external
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');
}
github leecade / react-native-swiper / examples / node_modules / react-native / packager / packager.js View on Github external
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);
}
github mikaelbr / markdowner / app.js View on Github external
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 }));
});