Hops Express
hops-express creates a minimal Express server which takes care of serving static assets and registering the (through hops-build generated) middleware.
hops-express doesn't generate the middleware itself but assumes that it is named server.js
inside the hopsConfig.cacheDir
(see hops-config for more details).
API
createApp()
createApp()
creates an Express app, applies all the middleware configuration and returns the app object ready to call app.listen(host, port)
on it.
startServer(callback)
startServer()
is a small wrapper around createApp()
and executes app.listen()
with the values provided through hops-config.
Target Audience
This package is intended for users that want to use server-side rendering with hops - be it on lambda, a local machine, heroku or anywhere else.
The node server contained in this app should be ready for production usage.
Example
serve.js
var hopsExpress = require('hops-express');
hopsExpress.startServer(function (error) {
if (error) {
console.error(error);
} else {
console.log('server started successfully');
}
});