@dvsa/appdev-api-common 0.10.1 → 0.10.3-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/http/index.d.ts +4 -4
- package/http/index.js +10 -4
- package/package.json +11 -2
package/http/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class HTTP {
|
|
|
18
18
|
* @param url
|
|
19
19
|
* @param options
|
|
20
20
|
*/
|
|
21
|
-
static get(url: string, options?: RequestInit): Promise<HTTPResponse>;
|
|
21
|
+
static get(url: string, options?: Omit<RequestInit, "method" | "body">): Promise<HTTPResponse>;
|
|
22
22
|
/**
|
|
23
23
|
* Performs an HTTP POST request.
|
|
24
24
|
* Note: This method will throw an HTTPError if the response is not ok (status code 200-299) to emulate Axios behaviour.
|
|
@@ -26,7 +26,7 @@ export declare class HTTP {
|
|
|
26
26
|
* @param body
|
|
27
27
|
* @param options
|
|
28
28
|
*/
|
|
29
|
-
static post<T>(url: string, body: T, options?: RequestInit): Promise<HTTPResponse>;
|
|
29
|
+
static post<T>(url: string, body: T, options?: Omit<RequestInit, "method" | "body">): Promise<HTTPResponse>;
|
|
30
30
|
/**
|
|
31
31
|
* Performs an HTTP PUT request.
|
|
32
32
|
* Note: This method will throw an HTTPError if the response is not ok (status code 200-299) to emulate Axios behaviour.
|
|
@@ -34,14 +34,14 @@ export declare class HTTP {
|
|
|
34
34
|
* @param body
|
|
35
35
|
* @param options
|
|
36
36
|
*/
|
|
37
|
-
static put<T>(url: string, body: T, options?: RequestInit): Promise<HTTPResponse>;
|
|
37
|
+
static put<T>(url: string, body: T, options?: Omit<RequestInit, "method" | "body">): Promise<HTTPResponse>;
|
|
38
38
|
/**
|
|
39
39
|
* Performs an HTTP DELETE request.
|
|
40
40
|
* Note: This method will throw an HTTPError if the response is not ok (status code 200-299) to emulate Axios behaviour.
|
|
41
41
|
* @param url
|
|
42
42
|
* @param options
|
|
43
43
|
*/
|
|
44
|
-
static delete(url: string, options?: RequestInit): Promise<HTTPResponse>;
|
|
44
|
+
static delete(url: string, options?: Omit<RequestInit, "method">): Promise<HTTPResponse>;
|
|
45
45
|
private static serialise;
|
|
46
46
|
}
|
|
47
47
|
export {};
|
package/http/index.js
CHANGED
|
@@ -36,10 +36,13 @@ class HTTP {
|
|
|
36
36
|
*/
|
|
37
37
|
static async post(url, body, options) {
|
|
38
38
|
const response = await fetch(url, {
|
|
39
|
+
...options,
|
|
39
40
|
method: "POST",
|
|
40
|
-
headers: {
|
|
41
|
+
headers: {
|
|
42
|
+
"Content-Type": "application/json",
|
|
43
|
+
...options?.headers,
|
|
44
|
+
},
|
|
41
45
|
body: JSON.stringify(body),
|
|
42
|
-
...options,
|
|
43
46
|
});
|
|
44
47
|
const serialisedResponse = await HTTP.serialise(response);
|
|
45
48
|
if (!response.ok) {
|
|
@@ -56,10 +59,13 @@ class HTTP {
|
|
|
56
59
|
*/
|
|
57
60
|
static async put(url, body, options) {
|
|
58
61
|
const response = await fetch(url, {
|
|
62
|
+
...options,
|
|
59
63
|
method: "PUT",
|
|
60
|
-
headers: {
|
|
64
|
+
headers: {
|
|
65
|
+
"Content-Type": "application/json",
|
|
66
|
+
...options?.headers,
|
|
67
|
+
},
|
|
61
68
|
body: JSON.stringify(body),
|
|
62
|
-
...options,
|
|
63
69
|
});
|
|
64
70
|
const serialisedResponse = await HTTP.serialise(response);
|
|
65
71
|
if (!response.ok) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvsa/appdev-api-common",
|
|
3
|
-
"version": "0.10.
|
|
4
|
-
"keywords": [
|
|
3
|
+
"version": "0.10.3-0",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"dvsa",
|
|
6
|
+
"nodejs",
|
|
7
|
+
"typescript"
|
|
8
|
+
],
|
|
5
9
|
"author": "DVSA",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/dvsa/appdev-packages.git",
|
|
13
|
+
"directory": "packages/appdev-common"
|
|
14
|
+
},
|
|
6
15
|
"description": "Utils library for common API functionality",
|
|
7
16
|
"publishConfig": {
|
|
8
17
|
"directory": "dist",
|