How to use hops-express - 10 common examples

To help you get started, we’ve selected a few hops-express 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 xing / hops / packages / cli / mixin.core.js View on Github external
require('hops-build').runBuild(argv, (error, stats) => {
              if (error) {
                console.error(error.stack.toString());
                process.exit(1);
              } else {
                console.log(
                  stats.toString({
                    chunks: false,
                    modules: false,
                    entrypoints: false,
                  }),
                  '\n'
                );
                require('hops-express').runServer(argv);
              }
            });
          } else {
github xing / hops / packages / cli / index.js View on Github external
hopsBuild.runBuild(program, function (error) {
    if (error) {
      callback ? callback(error) : console.error(error.stack.toString());
    } else {
      hopsExpress.startServer(callback);
    }
  });
}
github xing / hops / packages / build / lib / server.js View on Github external
var compiler = webpack(developConfig);
  var app = express();
  app.use(hopsExpressUtils.timings);
  app.use(
    webpackDevMiddleware(compiler, {
      noInfo: true,
      logLevel: 'warn',
      publicPath: developConfig.output.publicPath,
      watchOptions: developConfig.watchOptions,
      serverSideRender: true,
    })
  );
  app.use(webpackHotMiddleware(compiler));
  app.use(hopsExpressUtils.rewritePath);
  app.use(express.static(hopsConfig.buildDir, { redirect: false }));
  hopsExpressUtils.bootstrap(app, hopsConfig);
  hopsExpressUtils.registerMiddleware(
    app,
    createMiddleware(
      nodeConfig,
      nodeConfig.watchOptions || developConfig.watchOptions
    )
  );
  hopsExpressUtils.teardown(app, hopsConfig);
  hopsExpressUtils.run(app, callback);
}
github xing / hops / packages / build / lib / renderer.js View on Github external
module.exports = function createRenderer(webpackConfig, watchOptions) {
  var router = new express.Router();
  router.use(hopsExpressUtils.timings);
  hopsExpressUtils.bootstrap(router, hopsConfig);
  hopsExpressUtils.registerMiddleware(
    router,
    createMiddleware(webpackConfig, watchOptions)
  );
  return function(options) {
    if (typeof options === 'string') {
      options = { url: options };
    }
    return new Promise(function(resolve, reject) {
      var req = mocks.createRequest(options);
      var res = mocks.createResponse({
        eventEmitter: events.EventEmitter,
        request: req,
      });
      res.on('finish', function() {
        if (res.statusCode !== 200) {
github xing / hops / packages / build / lib / server.js View on Github external
var app = express();
  app.use(hopsExpressUtils.timings);
  app.use(
    webpackDevMiddleware(compiler, {
      noInfo: true,
      logLevel: 'warn',
      publicPath: developConfig.output.publicPath,
      watchOptions: developConfig.watchOptions,
      serverSideRender: true,
    })
  );
  app.use(webpackHotMiddleware(compiler));
  app.use(hopsExpressUtils.rewritePath);
  app.use(express.static(hopsConfig.buildDir, { redirect: false }));
  hopsExpressUtils.bootstrap(app, hopsConfig);
  hopsExpressUtils.registerMiddleware(
    app,
    createMiddleware(
      nodeConfig,
      nodeConfig.watchOptions || developConfig.watchOptions
    )
  );
  hopsExpressUtils.teardown(app, hopsConfig);
  hopsExpressUtils.run(app, callback);
}
github xing / hops / packages / build / lib / renderer.js View on Github external
module.exports = function createRenderer(webpackConfig, watchOptions) {
  var router = new express.Router();
  router.use(hopsExpressUtils.timings);
  hopsExpressUtils.bootstrap(router, hopsConfig);
  hopsExpressUtils.registerMiddleware(
    router,
    createMiddleware(webpackConfig, watchOptions)
  );
  return function(options) {
    if (typeof options === 'string') {
      options = { url: options };
    }
    return new Promise(function(resolve, reject) {
      var req = mocks.createRequest(options);
      var res = mocks.createResponse({
        eventEmitter: events.EventEmitter,
        request: req,
      });
      res.on('finish', function() {
        if (res.statusCode !== 200) {
          reject(new Error('invalid status code: ' + res.statusCode));
github xing / hops / packages / spec / serve.spec.js View on Github external
require('hops-build').runBuild({ clean: true }, function() {
      require('hops-express').runServer({}, function(error, _app) {
        app = _app;
        port = app.address().port;
        done(error);
      });
    });
  });
github xing / hops / packages / local-cli / commands / serve.js View on Github external
handler: function serveHandler (argv) {
      if (argv.production) {
        process.env.NODE_ENV = 'production';
      }
      process.env.HOPS_MODE = argv.static ? 'static' : 'dynamic';
      hopsExpress.startServer(callback);
    }
  };
github xing / hops / packages / build / lib / server.js View on Github external
'use strict';

var express = require('express');

var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');

var hopsConfig = require('hops-config');
var hopsBuildConfig = require('hops-build-config');
var hopsExpressUtils = require('hops-express').utils;

var createMiddleware = require('./middleware');
var cleanup = require('./cleanup');

var developConfig = hopsBuildConfig.develop;
var nodeConfig = hopsBuildConfig.node;

process.on('unhandledRejection', function(error) {
  throw error;
});

function runDevelop(options, callback) {
  var compiler = webpack(developConfig);
  var app = express();
  app.use(hopsExpressUtils.timings);
  app.use(
github xing / hops / packages / build / lib / renderer.js View on Github external
'use strict';

var events = require('events');

var express = require('express');
var mocks = require('node-mocks-http');

var hopsConfig = require('hops-config');
var hopsExpressUtils = require('hops-express').utils;

var createMiddleware = require('./middleware');

module.exports = function createRenderer(webpackConfig, watchOptions) {
  var router = new express.Router();
  router.use(hopsExpressUtils.timings);
  hopsExpressUtils.bootstrap(router, hopsConfig);
  hopsExpressUtils.registerMiddleware(
    router,
    createMiddleware(webpackConfig, watchOptions)
  );
  return function(options) {
    if (typeof options === 'string') {
      options = { url: options };
    }
    return new Promise(function(resolve, reject) {