mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
781ac9ac25
* docs: add docs for theme and filter plugins * typos * typos * Create strong-socks-type.md * Update plugins.md * typos
1.3 KiB
1.3 KiB
id | title |
---|---|
plugin-filter | Filter Plugin |
What's a filter plugin?
:::caution
Filter plugins are experimental and requires more users feedback
:::caution
When to use a filter plugin?
If you need to mutate the metadata for different reasons this is a way to do it, all manifest request are intercepted, but the tarballs, user, profile or tokens requests are not included. A good example to review is the verdaccio-plugin-secfilter.
Plugin structure
The plugin only has one async method named filter_metadata
that reference of the manifest and must return a copy (or modified object but not recommended) of the metadata.
export default class VerdaccioMiddlewarePlugin implements IPluginStorageFilter<CustomConfig> {
async filter_metadata(metadata: Readonly<Manifest>): Promise<Package> {
// modify the metadata
const newMetadata = { ...metadata, ...{ name: 'fooName' } };
return newMetadata;
}
}
Configuration
Just add filters
to the config.yaml
file and your own plugin options.
filters:
storage-filter-blackwhitelist:
filter_file: /path/to/file
More info in the PR.