This commit is contained in:
Benjamin Toby 2025-01-09 14:35:19 +01:00
parent 9f256832ee
commit 549d0abc02
5 changed files with 17 additions and 7 deletions

View File

@ -1,2 +1,6 @@
declare const _exports: import("../../types").HttpRequestFunctionType; export = httpRequest;
export = _exports; /**
* # Generate a http Request
* @type {import("../../types").HttpRequestFunction}
*/
declare const httpRequest: import("../../types").HttpRequestFunction;

View File

@ -8,9 +8,9 @@ const _ = require("lodash");
/** /**
* # Generate a http Request * # Generate a http Request
* @type {import("../../types").HttpRequestFunctionType} * @type {import("../../types").HttpRequestFunction}
*/ */
module.exports = function httpRequest(params) { const httpRequest = (params) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const isUrlEncodedFormBody = params.urlEncodedFormBody; const isUrlEncodedFormBody = params.urlEncodedFormBody;
@ -81,6 +81,7 @@ module.exports = function httpRequest(params) {
status: response.statusCode || 404, status: response.statusCode || 404,
data, data,
str, str,
requestedPath: finalPath,
}); });
}); });
@ -89,6 +90,7 @@ module.exports = function httpRequest(params) {
status: response.statusCode || 404, status: response.statusCode || 404,
str, str,
error: err.message, error: err.message,
requestedPath: finalPath,
}); });
}); });
} }
@ -105,3 +107,5 @@ module.exports = function httpRequest(params) {
httpsRequest.end(); httpsRequest.end();
}); });
}; };
module.exports = httpRequest;

View File

@ -1235,7 +1235,7 @@ export type HttpRequestParams<ReqObj extends {
query?: ReqObj; query?: ReqObj;
urlEncodedFormBody?: boolean; urlEncodedFormBody?: boolean;
}; };
export type HttpRequestFunctionType<ReqObj extends { export type HttpRequestFunction<ReqObj extends {
[key: string]: any; [key: string]: any;
} = { } = {
[key: string]: any; [key: string]: any;
@ -1253,5 +1253,6 @@ export type HttpFunctionResponse<ResObj extends {
data?: ResObj; data?: ResObj;
error?: string; error?: string;
str?: string; str?: string;
requestedPath?: string;
}; };
export {}; export {};

View File

@ -1453,7 +1453,7 @@ export type HttpRequestParams<
urlEncodedFormBody?: boolean; urlEncodedFormBody?: boolean;
}; };
export type HttpRequestFunctionType< export type HttpRequestFunction<
ReqObj extends { [key: string]: any } = { [key: string]: any }, ReqObj extends { [key: string]: any } = { [key: string]: any },
ResObj extends { [key: string]: any } = { [key: string]: any } ResObj extends { [key: string]: any } = { [key: string]: any }
> = (param: HttpRequestParams<ReqObj>) => Promise<HttpFunctionResponse<ResObj>>; > = (param: HttpRequestParams<ReqObj>) => Promise<HttpFunctionResponse<ResObj>>;
@ -1465,4 +1465,5 @@ export type HttpFunctionResponse<
data?: ResObj; data?: ResObj;
error?: string; error?: string;
str?: string; str?: string;
requestedPath?: string;
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/datasquirel", "name": "@moduletrace/datasquirel",
"version": "3.3.7", "version": "3.3.8",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"bin": { "bin": {