0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

docs: add config builder api docs

This commit is contained in:
Juan Picado 2023-04-18 22:54:12 +02:00
parent 0dafa98263
commit bb4aabcae5
2 changed files with 56 additions and 0 deletions

View file

@ -349,3 +349,31 @@ experiments:
```
> To disable the experiments warning in the console, you must comment out the whole `experiments` section.
### Config Builder API {#builder}
After version `v5.23.1` the new advanced configuration builder API is available. The API is a flexible way to generate programmatically configuration outputs either in JSON or YAML using the builder pattern, for example:
```typescript
import { ConfigBuilder } from 'verdaccio';
const config = ConfigBuilder.build();
config
.addUplink('upstream', { url: 'https://registry.upstream.local' })
.addUplink('upstream2', { url: 'https://registry.upstream2.local' })
.addPackageAccess('upstream/*', {
access: 'public',
publish: 'foo, bar',
unpublish: 'foo, bar',
proxy: 'some',
})
.addLogger({ level: 'info', type: 'stdout', format: 'json' })
.addStorage('/tmp/verdaccio')
.addSecurity({ api: { legacy: true } });
// generate JSON object as output
config.getConfig();
// generate output as yaml
config.getAsYaml();
```

View file

@ -340,3 +340,31 @@ experiments:
```
> To disable the experiments warning in the console, you must comment out the whole `experiments` section.
### Config Builder API {#builder}
After version `v5.23.1` the new advanced configuration builder API is available. The API is a flexible way to generate programmatically configuration outputs either in JSON or YAML using the builder pattern, for example:
```typescript
import { ConfigBuilder } from 'verdaccio';
const config = ConfigBuilder.build();
config
.addUplink('upstream', { url: 'https://registry.upstream.local' })
.addUplink('upstream2', { url: 'https://registry.upstream2.local' })
.addPackageAccess('upstream/*', {
access: 'public',
publish: 'foo, bar',
unpublish: 'foo, bar',
proxy: 'some',
})
.addLogger({ level: 'info', type: 'stdout', format: 'json' })
.addStorage('/tmp/verdaccio')
.addSecurity({ api: { legacy: true } });
// generate JSON object as output
config.getConfig();
// generate output as yaml
config.getAsYaml();
```