mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
chore: move agent_options to config (#4942)
* chore: move agent_options to config * changeset
This commit is contained in:
parent
35360c8bbe
commit
e308fbbf3a
4 changed files with 19 additions and 12 deletions
6
.changeset/clever-bees-happen.md
Normal file
6
.changeset/clever-bees-happen.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@verdaccio/types': patch
|
||||
'@verdaccio/proxy': patch
|
||||
---
|
||||
|
||||
chore: move agent_options to config
|
|
@ -1,3 +1,6 @@
|
|||
import { AgentOptions as HttpAgentOptions } from 'node:http';
|
||||
import { AgentOptions as HttpsAgentOptions } from 'node:https';
|
||||
|
||||
import { PackageAccess, PackageList } from '@verdaccio/types/src/manifest';
|
||||
|
||||
export type TypeToken = 'Bearer' | 'Basic';
|
||||
|
@ -47,6 +50,8 @@ export interface Headers {
|
|||
[key: string]: string;
|
||||
}
|
||||
|
||||
export type AgentOptionsConf = HttpAgentOptions | HttpsAgentOptions;
|
||||
|
||||
export interface UpLinkTokenConf {
|
||||
type: TypeToken;
|
||||
token?: string;
|
||||
|
@ -64,6 +69,7 @@ export interface UpLinkConf {
|
|||
headers?: Headers;
|
||||
auth?: UpLinkTokenConf;
|
||||
strict_ssl?: boolean | void;
|
||||
agent_options?: AgentOptionsConf;
|
||||
_autogenerated?: boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
import { Agents } from 'got-cjs';
|
||||
import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent';
|
||||
import { Agent as HttpAgent, AgentOptions as HttpAgentOptions } from 'http';
|
||||
import { Agent as HttpsAgent, AgentOptions as HttpsAgentOptions } from 'https';
|
||||
import { Agent as HttpAgent } from 'http';
|
||||
import { Agent as HttpsAgent } from 'https';
|
||||
import { URL } from 'url';
|
||||
|
||||
export type AgentOptionsConf = HttpAgentOptions | HttpsAgentOptions;
|
||||
import { AgentOptionsConf } from '@verdaccio/types';
|
||||
|
||||
class CustomAgents {
|
||||
private url: string;
|
||||
private proxy: string | undefined;
|
||||
private agentOptions: HttpAgentOptions | HttpsAgentOptions;
|
||||
private agentOptions: AgentOptionsConf;
|
||||
private agent: Agents;
|
||||
public constructor(
|
||||
url: string,
|
||||
proxy: string | undefined,
|
||||
agentOptions: HttpAgentOptions | HttpsAgentOptions
|
||||
) {
|
||||
public constructor(url: string, proxy: string | undefined, agentOptions: AgentOptionsConf) {
|
||||
this.proxy = proxy;
|
||||
this.url = url;
|
||||
this.agentOptions = agentOptions;
|
||||
|
|
|
@ -22,11 +22,10 @@ import {
|
|||
errorUtils,
|
||||
searchUtils,
|
||||
} from '@verdaccio/core';
|
||||
import { Manifest } from '@verdaccio/types';
|
||||
import { Config, Logger, UpLinkConf } from '@verdaccio/types';
|
||||
import { AgentOptionsConf, Config, Logger, Manifest, UpLinkConf } from '@verdaccio/types';
|
||||
import { buildToken } from '@verdaccio/utils';
|
||||
|
||||
import CustomAgents, { AgentOptionsConf } from './agent';
|
||||
import CustomAgents from './agent';
|
||||
import { parseInterval } from './proxy-utils';
|
||||
|
||||
const debug = buildDebug('verdaccio:proxy');
|
||||
|
|
Loading…
Reference in a new issue