mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-21 23:45:12 +00:00
Apply suggestions from code review
Co-authored-by: anatawa12 <anatawa12@icloud.com>
This commit is contained in:
parent
7ccccf5545
commit
663c06be00
1 changed files with 17 additions and 17 deletions
|
@ -26,21 +26,24 @@ export type HttpRequestSendOptions = {
|
||||||
validators?: ((res: Response) => void)[];
|
validators?: ((res: Response) => void)[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable()
|
declare module 'node:http' {
|
||||||
|
interface Agent {
|
||||||
|
createConnection(options: net.NetConnectOpts, callback?: (err: unknown, stream: net.Socket) => void): net.Socket;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class HttpRequestServiceAgent extends http.Agent {
|
class HttpRequestServiceAgent extends http.Agent {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.config)
|
|
||||||
private config: Config,
|
private config: Config,
|
||||||
|
options?: http.AgentOptions,
|
||||||
options?: Object
|
|
||||||
) {
|
) {
|
||||||
super(options);
|
super(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public createConnection(options: Object, callback?: Function): net.Socket {
|
public createConnection(options: net.NetConnectOpts, callback?: (err: unknown, stream: net.Socket) => void): net.Socket {
|
||||||
const socket = super.createConnection(options, callback)
|
const socket = super.createConnection(options, callback)
|
||||||
.on('connect', ()=>{
|
.on('connect', () => {
|
||||||
const address = socket.remoteAddress;
|
const address = socket.remoteAddress;
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
if (address && ipaddr.isValid(address)) {
|
if (address && ipaddr.isValid(address)) {
|
||||||
|
@ -68,13 +71,10 @@ class HttpRequestServiceAgent extends http.Agent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
class HttpsRequestServiceAgent extends https.Agent {
|
class HttpsRequestServiceAgent extends https.Agent {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.config)
|
|
||||||
private config: Config,
|
private config: Config,
|
||||||
|
options?: https.AgentOptions,
|
||||||
options?: Object
|
|
||||||
) {
|
) {
|
||||||
super(options);
|
super(options);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue