This commit is contained in:
Benjamin Toby
2024-12-10 15:20:48 +01:00
parent 04a4452821
commit 2ae4610dca
8 changed files with 34 additions and 14 deletions
+6 -2
View File
@@ -1,5 +1,9 @@
declare function _exports({ request }: {
request: http.IncomingMessage;
}): any | null;
request?: http.IncomingMessage & {
[x: string]: any;
};
}): {
[x: string]: any;
};
export = _exports;
import http = require("http");
+4 -8
View File
@@ -16,22 +16,18 @@ const http = require("http");
* @async
*
* @param {object} params - main params object
* @param {http.IncomingMessage} params.request - HTTPS request object
* @param {http.IncomingMessage & Object<string, any>} [params.request] - HTTPS request object
*
* @returns {any | null}
* @returns {Object<string, any>}
*/
module.exports = function ({ request }) {
/**
* Check inputs
*
* @description Check inputs
*/
if (!request) return {};
/** @type {string | undefined} */
const cookieString = request.headers.cookie;
if (!cookieString || typeof cookieString !== "string") {
return null;
return {};
}
/** @type {string[]} */
+2
View File
@@ -0,0 +1,2 @@
export = serializeQuery;
declare function serializeQuery(param0: import("../types").SerializeQueryParams): string;
+18
View File
@@ -0,0 +1,18 @@
// @ts-check
/** @type {import("../types").SerializeQueryFnType} */
function serializeQuery({ query }) {
let str = "?";
const keys = Object.keys(query);
/** @type {string[]} */
const queryArr = [];
keys.forEach((key) => {
if (!key || !query[key]) return;
queryArr.push(`${key}=${query[key]}`);
});
str += queryArr.join("&");
return str;
}
module.exports = serializeQuery;