diff --git a/README.md b/README.md index d2d2acc..f962d0f 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,10 @@ Many aspects of the explorer are configurable. See [options](#options) for a description of these options: ```js +// Mount middleware before calling `explorer()` to add custom headers, auth, etc. +app.use('/explorer', loopback.basicAuth('user', 'password')); app.use('/explorer', explorer(app, { basePath: '/custom-api-root', - preMiddleware: [ - // You can add as many items to this middleware chain as you like - loopback.basicAuth(bitmex.settings.basicAuth.user, bitmex.settings.basicAuth.password) - ], swaggerDistRoot: '/swagger', apiInfo: { 'title': 'My API', @@ -59,7 +57,6 @@ Options are passed to `explorer(app, options)`. > to a path different than '/api', e.g. with > `loopback.use('/custom-api-root', loopback.rest()); - `swaggerDistRoot`: **String** > Sets a path within your application for overriding Swagger UI files. @@ -89,9 +86,3 @@ Options are passed to `explorer(app, options)`. > Default: Read from package.json > Sets your API version. If not present, will read from your app's package.json. - -`preMiddleware`: **Array|Function** - -> Middleware to run before any explorer routes, including static routes. - -> Useful for setting HTTP Auth, modifying the `Host` header, and so on. diff --git a/index.js b/index.js index 3c2aaa4..af5d12d 100644 --- a/index.js +++ b/index.js @@ -23,21 +23,13 @@ module.exports = explorer; function explorer(loopbackApplication, options) { options = _defaults({}, options, { resourcePath: 'resources', - apiInfo: loopbackApplication.get('apiInfo') || {}, - preMiddleware: [] + apiInfo: loopbackApplication.get('apiInfo') || {} }); var app = express(); swagger(loopbackApplication, app, options); - // Allow the user to attach middleware that will run before any - // explorer routes, e.g. for access control. - if (typeof options.preMiddleware === 'function' || - (Array.isArray(options.preMiddleware) && options.preMiddleware.length)) { - app.use(options.preMiddleware); - } - app.disable('x-powered-by'); // config.json is loaded by swagger-ui. The server should respond