@pristine-ts/common 0.0.188 → 0.0.192

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.
@@ -6,7 +6,7 @@ class Request {
6
6
  /**
7
7
  * The headers of the request.
8
8
  */
9
- this.headers = {};
9
+ this._headers = {};
10
10
  /**
11
11
  * The body of the request.
12
12
  */
@@ -14,6 +14,25 @@ class Request {
14
14
  this.httpMethod = httpMethod;
15
15
  this.url = url;
16
16
  }
17
+ /**
18
+ * This method returns all the headers.
19
+ */
20
+ get headers() {
21
+ return this._headers;
22
+ }
23
+ /**
24
+ * This method sets the headers appropriately.
25
+ *
26
+ * @param headers
27
+ */
28
+ setHeaders(headers) {
29
+ for (const name in headers) {
30
+ if (headers.hasOwnProperty(name) === false) {
31
+ continue;
32
+ }
33
+ this.setHeader(name, headers[name]);
34
+ }
35
+ }
17
36
  /**
18
37
  * This method sets a header parameter in the Request.
19
38
  *
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/models/request.ts"],"names":[],"mappings":";;;AAKA,MAAa,OAAO;IA0BhB,YAAY,UAA+B,EAAE,GAAW;QAfxD;;WAEG;QACH,YAAO,GAA8B,EAAE,CAAC;QAExC;;WAEG;QACH,SAAI,GAAQ,EAAE,CAAC;QAQX,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,IAAY,EAAE,KAAa;QACjC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5C,CAAC;CACJ;AA1DD,0BA0DC"}
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/models/request.ts"],"names":[],"mappings":";;;AAMA,MAAa,OAAO;IA0BhB,YAAY,UAA+B,EAAE,GAAW;QAfxD;;WAEG;QACK,aAAQ,GAA8B,EAAE,CAAC;QAEjD;;WAEG;QACH,SAAI,GAAQ,EAAE,CAAC;QAQX,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACI,UAAU,CAAC,OAAkC;QAChD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;YACxB,IAAG,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE;gBACvC,SAAS;aACZ;YAED,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;SACtC;IACL,CAAC;IAED;;;;;OAKG;IACI,SAAS,CAAC,IAAY,EAAE,KAAa;QACxC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5C,CAAC;CACJ;AAhFD,0BAgFC"}
@@ -7,6 +7,54 @@ class Response {
7
7
  * The status code of the response. By default we return a 200.
8
8
  */
9
9
  this.status = 200;
10
+ /**
11
+ * The headers of the response.
12
+ */
13
+ this._headers = {};
14
+ }
15
+ /**
16
+ * This method returns all the headers.
17
+ */
18
+ get headers() {
19
+ return this._headers;
20
+ }
21
+ /**
22
+ * This method sets the headers appropriately.
23
+ *
24
+ * @param headers
25
+ */
26
+ setHeaders(headers) {
27
+ for (const name in headers) {
28
+ if (headers.hasOwnProperty(name) === false) {
29
+ continue;
30
+ }
31
+ this.setHeader(name, headers[name]);
32
+ }
33
+ }
34
+ /**
35
+ * This method sets a header parameter in the Response.
36
+ *
37
+ * @param name The name of the header.
38
+ * @param value The value of the header.
39
+ */
40
+ setHeader(name, value) {
41
+ this.headers[name.toLowerCase()] = value;
42
+ }
43
+ /**
44
+ * This method returns whether or not the header exists in the Response.
45
+ *
46
+ * @param name The name of the header.
47
+ */
48
+ hasHeader(name) {
49
+ return this.headers.hasOwnProperty(name.toLowerCase());
50
+ }
51
+ /**
52
+ * This method returns the header corresponding to the name or undefined if it doesn't exist.
53
+ *
54
+ * @param name The name of the header.
55
+ */
56
+ getHeader(name) {
57
+ return this.headers[name.toLowerCase()];
10
58
  }
11
59
  }
12
60
  exports.Response = Response;
@@ -1 +1 @@
1
- {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/models/response.ts"],"names":[],"mappings":";;;AAKA,MAAa,QAAQ;IAArB;QACI;;WAEG;QACH,WAAM,GAAW,GAAG,CAAC;IAgBzB,CAAC;CAAA;AApBD,4BAoBC"}
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/models/response.ts"],"names":[],"mappings":";;;AAKA,MAAa,QAAQ;IAArB;QACI;;WAEG;QACH,WAAM,GAAW,GAAG,CAAC;QAErB;;WAEG;QACK,aAAQ,GAA8B,EAAE,CAAC;IA4DrD,CAAC;IAjDG;;OAEG;IACH,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACI,UAAU,CAAC,OAAkC;QAChD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;YACxB,IAAG,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE;gBACvC,SAAS;aACZ;YAED,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;SACtC;IACL,CAAC;IAED;;;;;OAKG;IACI,SAAS,CAAC,IAAY,EAAE,KAAa;QACxC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5C,CAAC;CACJ;AArED,4BAqEC"}
@@ -3,7 +3,7 @@ export class Request {
3
3
  /**
4
4
  * The headers of the request.
5
5
  */
6
- this.headers = {};
6
+ this._headers = {};
7
7
  /**
8
8
  * The body of the request.
9
9
  */
@@ -11,6 +11,25 @@ export class Request {
11
11
  this.httpMethod = httpMethod;
12
12
  this.url = url;
13
13
  }
14
+ /**
15
+ * This method returns all the headers.
16
+ */
17
+ get headers() {
18
+ return this._headers;
19
+ }
20
+ /**
21
+ * This method sets the headers appropriately.
22
+ *
23
+ * @param headers
24
+ */
25
+ setHeaders(headers) {
26
+ for (const name in headers) {
27
+ if (headers.hasOwnProperty(name) === false) {
28
+ continue;
29
+ }
30
+ this.setHeader(name, headers[name]);
31
+ }
32
+ }
14
33
  /**
15
34
  * This method sets a header parameter in the Request.
16
35
  *
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/models/request.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,OAAO;IA0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IAAI,CAAC,CAAC,CAAA;SACtC;IACL,CAAC;IAED;;;;;OAKG;IACI,SAAS,CAAC,IAAY,EAAE,KAAa;QACxC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5C,CAAC;CACJ"}
@@ -4,6 +4,54 @@ export class Response {
4
4
  * The status code of the response. By default we return a 200.
5
5
  */
6
6
  this.status = 200;
7
+ /**
8
+ * The headers of the response.
9
+ */
10
+ this._headers = {};
11
+ }
12
+ /**
13
+ * This method returns all the headers.
14
+ */
15
+ get headers() {
16
+ return this._headers;
17
+ }
18
+ /**
19
+ * This method sets the headers appropriately.
20
+ *
21
+ * @param headers
22
+ */
23
+ setHeaders(headers) {
24
+ for (const name in headers) {
25
+ if (headers.hasOwnProperty(name) === false) {
26
+ continue;
27
+ }
28
+ this.setHeader(name, headers[name]);
29
+ }
30
+ }
31
+ /**
32
+ * This method sets a header parameter in the Response.
33
+ *
34
+ * @param name The name of the header.
35
+ * @param value The value of the header.
36
+ */
37
+ setHeader(name, value) {
38
+ this.headers[name.toLowerCase()] = value;
39
+ }
40
+ /**
41
+ * This method returns whether or not the header exists in the Response.
42
+ *
43
+ * @param name The name of the header.
44
+ */
45
+ hasHeader(name) {
46
+ return this.headers.hasOwnProperty(name.toLowerCase());
47
+ }
48
+ /**
49
+ * This method returns the header corresponding to the name or undefined if it doesn't exist.
50
+ *
51
+ * @param name The name of the header.
52
+ */
53
+ getHeader(name) {
54
+ return this.headers[name.toLowerCase()];
7
55
  }
8
56
  }
9
57
  //# sourceMappingURL=response.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/models/response.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,QAAQ;IAArB;QACI;;WAEG;QACH,WAAM,GAAW,GAAG,CAAC;IAgBzB,CAAC;CAAA"}
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/models/response.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,QAAQ;IAArB;QACI;;WAEG;QACH,WAAM,GAAW,GAAG,CAAC;QAErB;;WAEG;QACK,aAAQ,GAA8B,EAAE,CAAC;IA4DrD,CAAC;IAjDG;;OAEG;IACH,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACI,UAAU,CAAC,OAAkC;QAChD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;YACxB,IAAG,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE;gBACvC,SAAS;aACZ;YAED,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;SACtC;IACL,CAAC;IAED;;;;;OAKG;IACI,SAAS,CAAC,IAAY,EAAE,KAAa;QACxC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5C,CAAC;CACJ"}
@@ -14,9 +14,7 @@ export declare class Request {
14
14
  /**
15
15
  * The headers of the request.
16
16
  */
17
- headers: {
18
- [key: string]: string;
19
- };
17
+ private _headers;
20
18
  /**
21
19
  * The body of the request.
22
20
  */
@@ -26,6 +24,20 @@ export declare class Request {
26
24
  */
27
25
  rawBody?: any;
28
26
  constructor(httpMethod: HttpMethod | string, url: string);
27
+ /**
28
+ * This method returns all the headers.
29
+ */
30
+ get headers(): {
31
+ [key: string]: string;
32
+ };
33
+ /**
34
+ * This method sets the headers appropriately.
35
+ *
36
+ * @param headers
37
+ */
38
+ setHeaders(headers: {
39
+ [key: string]: string;
40
+ }): void;
29
41
  /**
30
42
  * This method sets a header parameter in the Request.
31
43
  *
@@ -10,9 +10,7 @@ export declare class Response {
10
10
  /**
11
11
  * The headers of the response.
12
12
  */
13
- headers?: {
14
- [key: string]: string;
15
- };
13
+ private _headers;
16
14
  /**
17
15
  * The body of the response.
18
16
  */
@@ -21,4 +19,37 @@ export declare class Response {
21
19
  * The request that triggered this response.
22
20
  */
23
21
  request?: Request;
22
+ /**
23
+ * This method returns all the headers.
24
+ */
25
+ get headers(): {
26
+ [key: string]: string;
27
+ };
28
+ /**
29
+ * This method sets the headers appropriately.
30
+ *
31
+ * @param headers
32
+ */
33
+ setHeaders(headers: {
34
+ [key: string]: string;
35
+ }): void;
36
+ /**
37
+ * This method sets a header parameter in the Response.
38
+ *
39
+ * @param name The name of the header.
40
+ * @param value The value of the header.
41
+ */
42
+ setHeader(name: string, value: string): void;
43
+ /**
44
+ * This method returns whether or not the header exists in the Response.
45
+ *
46
+ * @param name The name of the header.
47
+ */
48
+ hasHeader(name: string): boolean;
49
+ /**
50
+ * This method returns the header corresponding to the name or undefined if it doesn't exist.
51
+ *
52
+ * @param name The name of the header.
53
+ */
54
+ getHeader(name: string): string | undefined;
24
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pristine-ts/common",
3
- "version": "0.0.188",
3
+ "version": "0.0.192",
4
4
  "description": "",
5
5
  "module": "dist/lib/esm/common.module.js",
6
6
  "main": "dist/lib/cjs/common.module.js",
@@ -8,7 +8,8 @@
8
8
  "scripts": {
9
9
  "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
10
10
  "prepublish": "npm run build",
11
- "test": "jest"
11
+ "test": "jest",
12
+ "test:cov": "jest --coverage"
12
13
  },
13
14
  "files": [
14
15
  "dist"
@@ -56,5 +57,5 @@
56
57
  "src/*.{js,ts}"
57
58
  ]
58
59
  },
59
- "gitHead": "d9eeadc798c023e887715ed55151f3a439eec442"
60
+ "gitHead": "3f78bc1ae1441441fb9b57fd98b9fd6667a4d28a"
60
61
  }