File tree Expand file tree Collapse file tree 6 files changed +23
-17
lines changed
Expand file tree Collapse file tree 6 files changed +23
-17
lines changed Original file line number Diff line number Diff line change @@ -20,18 +20,9 @@ export interface RegistryOptions<T = any>
2020 */
2121 discovery ?:
2222 | {
23- /**
24- * Enables the HTML discovery page
25- *
26- * @default true
27- */
2823 ui ?: boolean ;
29- /**
30- * Shows experimental components from the API
31- *
32- * @default true
33- */
3424 experimental ?: boolean ;
25+ api ?: boolean ;
3526 }
3627 | boolean ;
3728 /**
@@ -85,19 +76,25 @@ export default function optionsSanitiser(input: RegistryOptions): Config {
8576 options . verbosity = 0 ;
8677 }
8778
79+ const showApi =
80+ typeof options . discovery === 'boolean'
81+ ? true
82+ : ( options . discovery ?. api ?? true ) ;
8883 const showUI =
8984 typeof options . discovery === 'boolean'
9085 ? options . discovery
9186 : ( options . discovery ?. ui ?? true ) ;
92- const showExperimental =
93- typeof options . discovery === 'boolean'
87+ const showExperimental = ! showApi
88+ ? false
89+ : typeof options . discovery === 'boolean'
9490 ? // We keep previous default behavior for backward compatibility
9591 true
9692 : ( options . discovery ?. experimental ?? true ) ;
9793
9894 options . discovery = {
9995 ui : showUI ,
100- experimental : showExperimental
96+ experimental : showExperimental ,
97+ api : showApi
10198 } ;
10299
103100 if ( typeof options . pollingInterval === 'undefined' ) {
Original file line number Diff line number Diff line change @@ -77,12 +77,14 @@ function componentInfo(
7777 } )
7878 ) ;
7979 } ) ;
80- } else {
80+ } else if ( res . conf . discovery . api ) {
8181 res . status ( 200 ) . json (
8282 Object . assign ( component , {
8383 requestVersion : req . params [ 'componentVersion' ] || ''
8484 } )
8585 ) ;
86+ } else {
87+ res . status ( 401 ) ;
8688 }
8789}
8890
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import getAvailableDependencies from './helpers/get-available-dependencies';
44
55export default function dependencies ( conf : Config ) {
66 return ( _req : Request , res : Response ) : void => {
7- if ( res . conf . discovery . ui ) {
7+ if ( res . conf . discovery . api ) {
88 const dependencies = getAvailableDependencies ( conf . dependencies ) . map (
99 ( { core, name, version } ) => {
1010 const dep : { name : string ; core : boolean ; versions ?: string [ ] } = {
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ export default function (repository: Repository) {
106106 ) ;
107107 } else {
108108 const state = req . query [ 'state' ] || '' ;
109- const meta = req . query [ 'meta' ] === 'true' && res . conf . discovery . ui ;
109+ const meta = req . query [ 'meta' ] === 'true' && res . conf . discovery . api ;
110110 let list = componentResults ;
111111 if ( ! res . conf . discovery . experimental ) {
112112 list = list . filter (
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import type { Config } from '../../types';
33
44export default function plugins ( conf : Config ) {
55 return ( _req : Request , res : Response ) : void => {
6- if ( res . conf . discovery . ui ) {
6+ if ( res . conf . discovery . api ) {
77 const plugins = Object . entries ( conf . plugins ) . map (
88 ( [ pluginName , plugin ] ) => ( {
99 name : pluginName ,
Original file line number Diff line number Diff line change @@ -213,12 +213,19 @@ export interface Config<T = any> {
213213 * Configuration object to enable/disable the HTML discovery page and the API
214214 */
215215 discovery : {
216+ /**
217+ * Enables API discovery endpoints
218+ * @default true
219+ */
220+ api : boolean ;
216221 /**
217222 * Enables the HTML discovery page
223+ * @default true
218224 */
219225 ui : boolean ;
220226 /**
221227 * Shows experimental components from the API
228+ * @default true
222229 */
223230 experimental : boolean ;
224231 } ;
You can’t perform that action at this time.
0 commit comments