diff --git a/.gitignore b/.gitignore index 9e406a5..1adaa15 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules *.tgz +yarn.lock \ No newline at end of file diff --git a/README.md b/README.md index 90da32d..62c412f 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,12 @@ See [examples](examples/) for examples The following options are available: -* `showAuth`: Shows any hapi authentication scheme using _server.auth.strategy_. Default: false -* `showScope`: Shows route access rules using _route.options.auth.access.scope_. Default: false -* `showStart`: Shows route information during startup of server. Default: true +Option | Type | Description | Defaut +-|:-:|:-:|- +`showAuth` | boolean | Shows any hapi authentication scheme using _server.auth.strategy_ | `false` +`showScope` | boolean | Shows route access rules using _route.options.auth.access.scope_ | `false` +`showStart` | boolean | Shows route information during startup of server | `true` +`exclude` | array | Doesn't show specified routes. Routes should be a `string` type. Example, [`'/doc'`, `'/swagger'`] | `[ ]` The module also registers the _'info()'_ and _'text()'_ API methods: diff --git a/lib/index.js b/lib/index.js index 651f943..7ca883d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -13,7 +13,8 @@ const internals = { schema: { showAuth: Joi.boolean().default(false), showScope: Joi.boolean().default(false), - showStart: Joi.boolean().default(true) + showStart: Joi.boolean().default(true), + exclude: Joi.array().items(Joi.string().regex(/\/[a-zA-Z0-9.-]*/)).default([]) } }; @@ -70,6 +71,10 @@ internals.printableRoutes = function (routes, options) { routes.forEach((show) => { + if (options.exclude.includes(show.path)){ + return; + } + const row = { method: internals.formatMethod(show.method), path: internals.formatPath(show.path), diff --git a/test/index.js b/test/index.js index e547e9b..e580790 100644 --- a/test/index.js +++ b/test/index.js @@ -282,6 +282,24 @@ describe('routes', () => { expect(text).to.match(/findme.*api routes/); }); + it('exclude routes should be shown', async () => { + + const blippOptions = { + exclude: [ + '/api', + '/hi' + ] + }; + + const server = await internals.prepareServer({ blippOptions }); + + const info = server.plugins[Pkg.name].info(); + delete info[0].uri; + const text = server.plugins[Pkg.name].text(); + expect(text).to.not.match(/\/api/); + expect(text).to.not.match(/\/hi/); + }); + it('fails with invalid options', async () => { try {