Skip to content

Commit 60c7591

Browse files
VoltrexKeyvatargos
authored andcommitted
typings: add JSDoc typings for http
PR-URL: #38191 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent ec4be2d commit 60c7591

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

lib/http.js

+51
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,65 @@ const {
4242
} = require('_http_server');
4343
let maxHeaderSize;
4444

45+
/**
46+
* Returns a new instance of `http.Server`.
47+
* @param {{
48+
* IncomingMessage?: IncomingMessage;
49+
* ServerResponse?: ServerResponse;
50+
* insecureHTTPParser?: boolean;
51+
* maxHeaderSize?: number;
52+
* }} [opts]
53+
* @param {Function} [requestListener]
54+
* @returns {Server}
55+
*/
4556
function createServer(opts, requestListener) {
4657
return new Server(opts, requestListener);
4758
}
4859

60+
/**
61+
* @typedef {Object} HTTPRequestOptions
62+
* @property {httpAgent.Agent | boolean} [agent]
63+
* @property {string} [auth]
64+
* @property {Function} [createConnection]
65+
* @property {number} [defaultPort]
66+
* @property {number} [family]
67+
* @property {Object} [headers]
68+
* @property {number} [hints]
69+
* @property {string} [host]
70+
* @property {string} [hostname]
71+
* @property {boolean} [insecureHTTPParser]
72+
* @property {string} [localAddress]
73+
* @property {number} [localPort]
74+
* @property {Function} [lookup]
75+
* @property {number} [maxHeaderSize]
76+
* @property {string} [method]
77+
* @property {string} [path]
78+
* @property {number} [port]
79+
* @property {string} [protocol]
80+
* @property {boolean} [setHost]
81+
* @property {string} [socketPath]
82+
* @property {number} [timeout]
83+
* @property {AbortSignal} [signal]
84+
*/
85+
86+
/**
87+
* Makes an HTTP request.
88+
* @param {string | URL} url
89+
* @param {HTTPRequestOptions} [options]
90+
* @param {Function} [cb]
91+
* @returns {ClientRequest}
92+
*/
4993
function request(url, options, cb) {
5094
return new ClientRequest(url, options, cb);
5195
}
5296

97+
/**
98+
* Makes a `GET` HTTP request.
99+
* @param {string | URL} url
100+
* @param {HTTPRequestOptions} [options]
101+
* @param {Function} [cb]
102+
* @returns {ClientRequest}
103+
*/
53104
function get(url, options, cb) {
54105
const req = request(url, options, cb);
55106
req.end();

0 commit comments

Comments
 (0)