How to use the hops-express.utils.registerMiddleware function in hops-express

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 / 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));