This package is deprecated. Please use hops-express instead.
Hops server is a small collection of shared functionality that can be used in express-like interfaces to register the hops-middleware.
It also exports a simple middleware that takes care of rewriting the paths of incoming http requests based on the values set in hops-config.
rewritePath(request, response, next) => void
rewritePathis an express-style middleware that adds a trailing slash to the url of the incoming request.
registerMiddleware(app, middleware) => void
registerMiddlewareis a helper function that registers a wildcard middleware for every location defined in the hops-config, if available. Otherwise it registers the given middleware for a wildcard route at the root.
run(app, callback) => void
runis a helper function that starts the express-like server with the parameters defined in hops-config.
bootstrap(app, hopsConfig) => void
teardown(app, hopsConfig) => voidThese functions allow to customize the server through hops-config. It is possible to define
hopsConfig.teardownServerto override these functions and execute some custom logic on the
If you want to build an express-like server and reuse the hops-config while doing so, then this middleware will help dealing with the locations and basePath config.
var path = ;var express = ;var server = ;var hopsConfig = ;// middleware generated by hops-build, based on the webpack node configvar pathToGeneratedMiddleware = path;// generic Express server applicationvar app = ;app;// bootstrap and teardown provide hooks to customize the server through hops-configserver;server;server;// actually run applicationserver;