mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-03-11 02:15:57 -05:00
feat: verdaccio-audit support timeout option (#4718)
* feat: verdaccio-audit support timeout option * Create many-bees-tickle.md * Update audit.ts * update docs * Update README.md --------- Co-authored-by: Juan Picado <juanpicado19@gmail.com>
This commit is contained in:
parent
c31aec8336
commit
136e992bb9
8 changed files with 24 additions and 1 deletions
5
.changeset/many-bees-tickle.md
Normal file
5
.changeset/many-bees-tickle.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'verdaccio-audit': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: verdaccio-audit support timeout option
|
|
@ -187,6 +187,7 @@ server:
|
||||||
middlewares:
|
middlewares:
|
||||||
audit:
|
audit:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# timeout: 10000
|
||||||
|
|
||||||
# https://verdaccio.org/docs/logger
|
# https://verdaccio.org/docs/logger
|
||||||
# log settings
|
# log settings
|
||||||
|
|
|
@ -193,6 +193,7 @@ server:
|
||||||
middlewares:
|
middlewares:
|
||||||
audit:
|
audit:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# timeout: 10000
|
||||||
|
|
||||||
# https://verdaccio.org/docs/logger
|
# https://verdaccio.org/docs/logger
|
||||||
# log settings
|
# log settings
|
||||||
|
|
|
@ -26,6 +26,7 @@ middlewares:
|
||||||
audit:
|
audit:
|
||||||
enabled: true
|
enabled: true
|
||||||
strict_ssl: true # optional, defaults to true
|
strict_ssl: true # optional, defaults to true
|
||||||
|
timeout: 1000
|
||||||
```
|
```
|
||||||
|
|
||||||
### Strict SSL
|
### Strict SSL
|
||||||
|
|
|
@ -19,11 +19,13 @@ export default class ProxyAudit
|
||||||
public enabled: boolean;
|
public enabled: boolean;
|
||||||
public logger: Logger;
|
public logger: Logger;
|
||||||
public strict_ssl: boolean;
|
public strict_ssl: boolean;
|
||||||
|
public timeout: number;
|
||||||
|
|
||||||
public constructor(config: ConfigAudit, options: pluginUtils.PluginOptions) {
|
public constructor(config: ConfigAudit, options: pluginUtils.PluginOptions) {
|
||||||
super(config, options);
|
super(config, options);
|
||||||
this.enabled = config.enabled || false;
|
this.enabled = config.enabled || false;
|
||||||
this.strict_ssl = config.strict_ssl !== undefined ? config.strict_ssl : true;
|
this.strict_ssl = config.strict_ssl !== undefined ? config.strict_ssl : true;
|
||||||
|
this.timeout = config.timeout ?? 1000 * 60 * 1;
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +59,17 @@ export default class ProxyAudit
|
||||||
const auditEndpoint = `${REGISTRY_DOMAIN}${req.baseUrl}${req.route.path}`;
|
const auditEndpoint = `${REGISTRY_DOMAIN}${req.baseUrl}${req.route.path}`;
|
||||||
this.logger.debug('fetching audit from ' + auditEndpoint);
|
this.logger.debug('fetching audit from ' + auditEndpoint);
|
||||||
|
|
||||||
const response = await fetch(auditEndpoint, requestOptions);
|
const controller = new AbortController();
|
||||||
|
|
||||||
|
setTimeout(
|
||||||
|
() => controller.abort(`Fetch ${auditEndpoint} timeout ${this.timeout}ms`),
|
||||||
|
this.timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = await fetch(auditEndpoint, {
|
||||||
|
...requestOptions,
|
||||||
|
signal: controller.signal,
|
||||||
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
res.status(response.status).send(await response.json());
|
res.status(response.status).send(await response.json());
|
||||||
|
|
|
@ -2,4 +2,5 @@ export interface ConfigAudit {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
max_body?: string;
|
max_body?: string;
|
||||||
strict_ssl?: boolean;
|
strict_ssl?: boolean;
|
||||||
|
timeout?: number;
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,6 +364,7 @@ a built-in middleware plugin to handle this command.
|
||||||
middlewares:
|
middlewares:
|
||||||
audit:
|
audit:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# timeout: 10000
|
||||||
```
|
```
|
||||||
|
|
||||||
### Experiments {#experiments}
|
### Experiments {#experiments}
|
||||||
|
|
|
@ -387,6 +387,7 @@ a built-in middleware plugin to handle this command.
|
||||||
middlewares:
|
middlewares:
|
||||||
audit:
|
audit:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# timeout: 10000
|
||||||
```
|
```
|
||||||
|
|
||||||
### Experiments {#experiments}
|
### Experiments {#experiments}
|
||||||
|
|
Loading…
Add table
Reference in a new issue