Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions core/types/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"name": "@testring/types",
"version": "0.8.2",
"main": "./dist/index.js",
"types": "./src/index.ts",
"repository": {
"type": "git",
"url": "https://github.com/ringcentral/testring.git"
},
"scripts": {
"build": "tsc -p tsconfig.build.json"
},
"author": "RingCentral",
"license": "MIT",
"dependencies": {
"@types/node": "22.8.5"
}
"name": "@testring/types",
"version": "0.8.2",
"main": "./dist/index.js",
"types": "./src/index.ts",
"repository": {
"type": "git",
"url": "https://github.com/ringcentral/testring.git"
},
"scripts": {
"build": "tsc -p tsconfig.build.json"
},
"author": "RingCentral",
"license": "MIT",
"dependencies": {
"@types/node": "22.8.5",
"@types/request-promise-native": "1.0.21"
}
}
12 changes: 3 additions & 9 deletions core/types/src/http-api/structs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {RequestPromiseOptions} from 'request-promise-native';

interface IHttpHeaders {
[key: string]: any;
}
Expand All @@ -14,18 +16,10 @@ export interface IHttpResponse {
cookies: Array<any>;
}

export interface IHttpRequest {
export interface IHttpRequest extends RequestPromiseOptions {
url: string;
method?: 'POST' | 'GET' | 'PUT' | 'DELETE';
body?: any;
timeout?: number;
json?: any;
headers?: IHttpHeaders;
query?: IHttpQueryParameters;
cookies?: Array<any>;
simple?: boolean;
resolveWithFullResponse?: boolean;
gzip?: boolean;
}

export interface IHttpRequestMessage {
Expand Down
15 changes: 13 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 30 additions & 27 deletions packages/http-api/package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
{
"name": "@testring/http-api",
"version": "0.8.2",
"main": "./dist/index.js",
"types": "./src/index.ts",
"repository": {
"type": "git",
"url": "https://github.com/ringcentral/testring.git"
},
"scripts": {
"build": "tsc -p tsconfig.build.json"
},
"author": "RingCentral",
"license": "MIT",
"dependencies": {
"@testring/logger": "0.8.2",
"@testring/pluggable-module": "0.8.2",
"@testring/test-utils": "0.8.2",
"@testring/transport": "0.8.2",
"@testring/types": "0.8.2",
"@testring/utils": "0.8.2",
"@types/node": "22.8.5",
"@types/request-promise-native": "1.0.21",
"@types/tough-cookie": "4.0.5",
"request": "2.88.2",
"request-promise-native": "1.0.9",
"tough-cookie": "4.1.4"
}
"name": "@testring/http-api",
"version": "0.8.2",
"main": "./dist/index.js",
"types": "./src/index.ts",
"repository": {
"type": "git",
"url": "https://github.com/ringcentral/testring.git"
},
"scripts": {
"build": "tsc -p tsconfig.build.json"
},
"author": "RingCentral",
"license": "MIT",
"dependencies": {
"@testring/logger": "0.8.2",
"@testring/pluggable-module": "0.8.2",
"@testring/test-utils": "0.8.2",
"@testring/transport": "0.8.2",
"@testring/types": "0.8.2",
"@testring/utils": "0.8.2",
"@types/node": "22.8.5",
"@types/tough-cookie": "4.0.5",
"lodash": "4.17.21",
"request": "2.88.2",
"request-promise-native": "1.0.9",
"tough-cookie": "4.1.4"
},
"devDependencies": {
"@types/lodash": "4.17.20"
}
}
12 changes: 3 additions & 9 deletions packages/http-api/src/request-function.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {IHttpRequest, IHttpResponse} from '@testring/types';
import requestLib from 'request';
import requestPromise from 'request-promise-native';
import _ from 'lodash';

const toString = (c: requestLib.Cookie) => c.toString();

Expand Down Expand Up @@ -29,18 +30,11 @@ export async function requestFunction(
): Promise<IHttpResponse> {
const cookieJar = createCookieStore(request.cookies, request.url);

const rawRequest: requestPromise.RequestPromiseOptions & { url: string } = {
url: request.url,
const rawRequest = _.merge({}, request, {
qs: request.query,
body: request.body,
method: request.method,
timeout: request.timeout,
headers: request.headers,
json: request.json,
gzip: request.gzip,
jar: cookieJar,
resolveWithFullResponse: true,
};
});

const response = await requestPromise(rawRequest);
const cookies = cookieJar.getCookies(request.url).map(toString);
Expand Down