Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 {
hopsBuild.runBuild(program, function (error) {
if (error) {
callback ? callback(error) : console.error(error.stack.toString());
} else {
hopsExpress.startServer(callback);
}
});
}
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);
}
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) {
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);
}
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));
require('hops-build').runBuild({ clean: true }, function() {
require('hops-express').runServer({}, function(error, _app) {
app = _app;
port = app.address().port;
done(error);
});
});
});
handler: function serveHandler (argv) {
if (argv.production) {
process.env.NODE_ENV = 'production';
}
process.env.HOPS_MODE = argv.static ? 'static' : 'dynamic';
hopsExpress.startServer(callback);
}
};
'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(
'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) {