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 = _exports;
export = httpRequest;
/**
* # 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
* @type {import("../../types").HttpRequestFunctionType}
* @type {import("../../types").HttpRequestFunction}
*/
module.exports = function httpRequest(params) {
const httpRequest = (params) => {
return new Promise((resolve, reject) => {
const isUrlEncodedFormBody = params.urlEncodedFormBody;
@ -81,6 +81,7 @@ module.exports = function httpRequest(params) {
status: response.statusCode || 404,
data,
str,
requestedPath: finalPath,
});
});
@ -89,6 +90,7 @@ module.exports = function httpRequest(params) {
status: response.statusCode || 404,
str,
error: err.message,
requestedPath: finalPath,
});
});
}
@ -105,3 +107,5 @@ module.exports = function httpRequest(params) {
httpsRequest.end();
});
};
module.exports = httpRequest;

View File

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

View File

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

View File

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