nodecommons-esm-http 0.0.2

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.
Files changed (67) hide show
  1. package/dist/classes/commons-internal-http-client-implementation.d.mts +17 -0
  2. package/dist/classes/commons-internal-http-client-implementation.mjs +149 -0
  3. package/dist/classes/commons-internal-http-client-implementation.mjs.map +1 -0
  4. package/dist/classes/commons-streamable-http-client-implementation.d.mts +17 -0
  5. package/dist/classes/commons-streamable-http-client-implementation.mjs +151 -0
  6. package/dist/classes/commons-streamable-http-client-implementation.mjs.map +1 -0
  7. package/dist/enums/ecommons-strict-param-plurality.d.mts +5 -0
  8. package/dist/enums/ecommons-strict-param-plurality.mjs +7 -0
  9. package/dist/enums/ecommons-strict-param-plurality.mjs.map +1 -0
  10. package/dist/enums/ecommons-strict-param-type.d.mts +12 -0
  11. package/dist/enums/ecommons-strict-param-type.mjs +55 -0
  12. package/dist/enums/ecommons-strict-param-type.mjs.map +1 -0
  13. package/dist/helpers/commons-dns.d.mts +3 -0
  14. package/dist/helpers/commons-dns.mjs +36 -0
  15. package/dist/helpers/commons-dns.mjs.map +1 -0
  16. package/dist/helpers/commons-http-query-string.d.mts +4 -0
  17. package/dist/helpers/commons-http-query-string.mjs +39 -0
  18. package/dist/helpers/commons-http-query-string.mjs.map +1 -0
  19. package/dist/helpers/commons-http-response.d.mts +5 -0
  20. package/dist/helpers/commons-http-response.mjs +17 -0
  21. package/dist/helpers/commons-http-response.mjs.map +1 -0
  22. package/dist/helpers/commons-nginx-proxy-path.d.mts +1 -0
  23. package/dist/helpers/commons-nginx-proxy-path.mjs +6 -0
  24. package/dist/helpers/commons-nginx-proxy-path.mjs.map +1 -0
  25. package/dist/helpers/commons-ssl.d.mts +2 -0
  26. package/dist/helpers/commons-ssl.mjs +22 -0
  27. package/dist/helpers/commons-ssl.mjs.map +1 -0
  28. package/dist/helpers/commons-strict-params.d.mts +11 -0
  29. package/dist/helpers/commons-strict-params.mjs +165 -0
  30. package/dist/helpers/commons-strict-params.mjs.map +1 -0
  31. package/dist/helpers/commons-url.d.mts +5 -0
  32. package/dist/helpers/commons-url.mjs +30 -0
  33. package/dist/helpers/commons-url.mjs.map +1 -0
  34. package/dist/index.d.mts +22 -0
  35. package/dist/index.mjs +14 -0
  36. package/dist/index.mjs.map +1 -0
  37. package/dist/interfaces/commons-http-server.d.mts +14 -0
  38. package/dist/interfaces/commons-http-server.mjs +3 -0
  39. package/dist/interfaces/commons-http-server.mjs.map +1 -0
  40. package/dist/interfaces/hacks.d.mts +13 -0
  41. package/dist/interfaces/hacks.mjs +2 -0
  42. package/dist/interfaces/hacks.mjs.map +1 -0
  43. package/dist/interfaces/icommons-http-config.d.mts +5 -0
  44. package/dist/interfaces/icommons-http-config.mjs +9 -0
  45. package/dist/interfaces/icommons-http-config.mjs.map +1 -0
  46. package/dist/interfaces/icommons-strict-params-request.d.mts +4 -0
  47. package/dist/interfaces/icommons-strict-params-request.mjs +2 -0
  48. package/dist/interfaces/icommons-strict-params-request.mjs.map +1 -0
  49. package/dist/types/tcommons-http-handler.d.mts +3 -0
  50. package/dist/types/tcommons-http-handler.mjs +2 -0
  51. package/dist/types/tcommons-http-handler.mjs.map +1 -0
  52. package/dist/types/tcommons-http-request.d.mts +11 -0
  53. package/dist/types/tcommons-http-request.mjs +2 -0
  54. package/dist/types/tcommons-http-request.mjs.map +1 -0
  55. package/dist/types/tcommons-http-response.d.mts +5 -0
  56. package/dist/types/tcommons-http-response.mjs +3 -0
  57. package/dist/types/tcommons-http-response.mjs.map +1 -0
  58. package/dist/types/tcommons-strict-param-property-object.d.mts +4 -0
  59. package/dist/types/tcommons-strict-param-property-object.mjs +2 -0
  60. package/dist/types/tcommons-strict-param-property-object.mjs.map +1 -0
  61. package/dist/types/tcommons-strict-param-result.d.mts +1 -0
  62. package/dist/types/tcommons-strict-param-result.mjs +2 -0
  63. package/dist/types/tcommons-strict-param-result.mjs.map +1 -0
  64. package/dist/types/tcommons-strict-param.d.mts +8 -0
  65. package/dist/types/tcommons-strict-param.mjs +2 -0
  66. package/dist/types/tcommons-strict-param.mjs.map +1 -0
  67. package/package.json +34 -0
@@ -0,0 +1,17 @@
1
+ import { TEncodedObject } from 'tscommons-esm-core';
2
+ import { ICommonsHttpClientImplementation } from 'tscommons-esm-http';
3
+ import { THttpHeaderOrParamObject } from 'tscommons-esm-http';
4
+ import { TCommonsHttpInternalRequestOptions } from 'tscommons-esm-http';
5
+ import { ECommonsHttpContentType } from 'tscommons-esm-http';
6
+ import { ECommonsHttpResponseDataType } from 'tscommons-esm-http';
7
+ export declare class CommonsInternalHttpClientImplementation implements ICommonsHttpClientImplementation {
8
+ private static request;
9
+ private static requestHeadGetDelete;
10
+ private static requestPostPutPatch;
11
+ internalHead(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, options: TCommonsHttpInternalRequestOptions): Promise<void>;
12
+ internalGet(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): Promise<string | Uint8Array>;
13
+ internalDelete(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): Promise<string | Uint8Array>;
14
+ internalPost<B extends TEncodedObject = TEncodedObject>(url: string, body: B, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): Promise<string | Uint8Array>;
15
+ internalPut<B extends TEncodedObject = TEncodedObject>(url: string, body: B, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): Promise<string | Uint8Array>;
16
+ internalPatch<B extends TEncodedObject = TEncodedObject>(url: string, body: B, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): Promise<string | Uint8Array>;
17
+ }
@@ -0,0 +1,149 @@
1
+ import { URL } from 'url';
2
+ import * as https from 'https';
3
+ import * as http from 'http';
4
+ import { default as formurlencoded } from 'form-urlencoded';
5
+ import { commonsTypeHasPropertyString } from 'tscommons-esm-core';
6
+ import { CommonsHttpTimeoutError } from 'tscommons-esm-http';
7
+ import { commonsHttpBuildErrorFromResponseCode } from 'tscommons-esm-http';
8
+ import { ECommonsHttpContentType } from 'tscommons-esm-http';
9
+ import { ECommonsHttpResponseDataType } from 'tscommons-esm-http';
10
+ import { ECommonsHttpMethod } from 'tscommons-esm-http';
11
+ import { commonsHttpAppendEncodedObjectParams } from '../helpers/commons-http-query-string.mjs';
12
+ export class CommonsInternalHttpClientImplementation {
13
+ static request(protocol, options, bodyString, returnResult, responseDataType) {
14
+ return new Promise((resolve, reject) => {
15
+ let timedOut = false;
16
+ const request = protocol.request(options, (res) => {
17
+ if (responseDataType === ECommonsHttpResponseDataType.STRING)
18
+ res.setEncoding('utf8');
19
+ if (options.timeout)
20
+ res.setTimeout(options.timeout);
21
+ const rawData = [];
22
+ let stringData = '';
23
+ res.on('data', (chunk) => {
24
+ if (responseDataType === ECommonsHttpResponseDataType.UINT8ARRAY) {
25
+ rawData.push(Buffer.from(chunk)); // eslint-disable-line @typescript-eslint/no-unsafe-argument
26
+ }
27
+ else {
28
+ stringData += chunk;
29
+ }
30
+ });
31
+ res.on('end', () => {
32
+ if (res.statusCode && res.statusCode >= 400) {
33
+ // we only consider stringData for errors, even if we are actually in a raw request. It gets too complex trying to manage potential buffers for error messages.
34
+ try {
35
+ const json = JSON.parse(stringData); // eslint-disable-line @typescript-eslint/no-unsafe-assignment
36
+ if (commonsTypeHasPropertyString(json, 'message')) {
37
+ reject(commonsHttpBuildErrorFromResponseCode(res.statusCode, json.message));
38
+ }
39
+ else {
40
+ reject(commonsHttpBuildErrorFromResponseCode(res.statusCode, stringData));
41
+ }
42
+ }
43
+ catch (_e) {
44
+ reject(commonsHttpBuildErrorFromResponseCode(res.statusCode, stringData));
45
+ }
46
+ return;
47
+ }
48
+ if (!returnResult) {
49
+ resolve();
50
+ return;
51
+ }
52
+ if (responseDataType === ECommonsHttpResponseDataType.UINT8ARRAY) {
53
+ const concat = Buffer.concat(rawData);
54
+ // the resulting concat.buffer may not be purely the data, and there can be memory reuse, so we need to offset and length to avoid dirty data being returned
55
+ const uint8Array = new Uint8Array(concat.buffer, concat.byteOffset, concat.byteLength);
56
+ resolve(uint8Array);
57
+ return;
58
+ }
59
+ resolve(stringData);
60
+ });
61
+ });
62
+ request.on('error', (e) => {
63
+ // these are underpinning errors like socket errors rather than HTTP response codes (404, 500 etc.)
64
+ if (timedOut)
65
+ return; // ignore duplicate timeout error throws
66
+ reject(e);
67
+ });
68
+ if (options.timeout) {
69
+ request.on('timeout', () => {
70
+ timedOut = true; // prevent duplicate timeout error throws
71
+ reject(new CommonsHttpTimeoutError());
72
+ // do this after, as it might cause an error to be thrown itself
73
+ // it's a clean-up more than anything else
74
+ request.destroy();
75
+ });
76
+ request.setTimeout(options.timeout);
77
+ }
78
+ request.write(bodyString);
79
+ request.end();
80
+ });
81
+ }
82
+ static requestHeadGetDelete(method, url, params, headers, returnResult, responseDataType, timeout) {
83
+ const protocol = url.match(/^https:/) ? https : http;
84
+ if (params && Object.keys(params).length > 0) {
85
+ url = commonsHttpAppendEncodedObjectParams(url, params);
86
+ }
87
+ const urlObject = new URL(url);
88
+ const options = {
89
+ protocol: urlObject.protocol,
90
+ hostname: urlObject.hostname,
91
+ port: parseInt(urlObject.port, 10),
92
+ path: urlObject.search ? `${urlObject.pathname}${urlObject.search}` : urlObject.pathname,
93
+ method: method,
94
+ headers: headers,
95
+ timeout: timeout
96
+ };
97
+ return CommonsInternalHttpClientImplementation.request(protocol, options, '', returnResult, responseDataType);
98
+ }
99
+ static requestPostPutPatch(method, url, body, contentType, params, headers, returnResult, responseDataType, timeout) {
100
+ const protocol = url.match(/^https:/) ? https : http;
101
+ if (params && Object.keys(params).length > 0) {
102
+ url = commonsHttpAppendEncodedObjectParams(url, params);
103
+ }
104
+ const urlObject = new URL(url);
105
+ const options = {
106
+ protocol: urlObject.protocol,
107
+ hostname: urlObject.hostname,
108
+ port: parseInt(urlObject.port, 10),
109
+ path: urlObject.search ? `${urlObject.pathname}${urlObject.search}` : urlObject.pathname,
110
+ method: method,
111
+ headers: headers,
112
+ timeout: timeout
113
+ };
114
+ let bodyData = '';
115
+ switch (contentType) {
116
+ case ECommonsHttpContentType.JSON:
117
+ bodyData = JSON.stringify(body);
118
+ break;
119
+ case ECommonsHttpContentType.FORM_URL:
120
+ bodyData = formurlencoded(body);
121
+ break;
122
+ default:
123
+ throw new Error('Unknown encoding type');
124
+ }
125
+ // we can't do this in the tscommons-esm-http, as formurlencoded isn't used in Angular
126
+ options.headers['Content-Length'] = Buffer.byteLength(bodyData, 'utf-8').toString(10);
127
+ return this.request(protocol, options, bodyData, returnResult, responseDataType);
128
+ }
129
+ async internalHead(url, params, headers, options) {
130
+ await CommonsInternalHttpClientImplementation.requestHeadGetDelete(ECommonsHttpMethod.HEAD, url, params, headers, false, ECommonsHttpResponseDataType.UINT8ARRAY, // na
131
+ options.timeout);
132
+ }
133
+ internalGet(url, params, headers, responseDataType, options) {
134
+ return CommonsInternalHttpClientImplementation.requestHeadGetDelete(ECommonsHttpMethod.GET, url, params, headers, true, responseDataType, options.timeout);
135
+ }
136
+ internalDelete(url, params, headers, responseDataType, options) {
137
+ return CommonsInternalHttpClientImplementation.requestHeadGetDelete(ECommonsHttpMethod.DELETE, url, params, headers, true, responseDataType, options.timeout);
138
+ }
139
+ internalPost(url, body, params, headers, bodyDataEncoding, responseDataType, options) {
140
+ return CommonsInternalHttpClientImplementation.requestPostPutPatch(ECommonsHttpMethod.POST, url, body, bodyDataEncoding, params, headers, true, responseDataType, options.timeout);
141
+ }
142
+ internalPut(url, body, params, headers, bodyDataEncoding, responseDataType, options) {
143
+ return CommonsInternalHttpClientImplementation.requestPostPutPatch(ECommonsHttpMethod.PUT, url, body, bodyDataEncoding, params, headers, true, responseDataType, options.timeout);
144
+ }
145
+ internalPatch(url, body, params, headers, bodyDataEncoding, responseDataType, options) {
146
+ return CommonsInternalHttpClientImplementation.requestPostPutPatch(ECommonsHttpMethod.PATCH, url, body, bodyDataEncoding, params, headers, true, responseDataType, options.timeout);
147
+ }
148
+ }
149
+ //# sourceMappingURL=commons-internal-http-client-implementation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-internal-http-client-implementation.mjs","sourceRoot":"","sources":["../../src/classes/commons-internal-http-client-implementation.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAGlE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,qCAAqC,EAAE,MAAM,oBAAoB,CAAC;AAI3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,oCAAoC,EAAE,MAAM,0CAA0C,CAAC;AAMhG,MAAM,OAAO,uCAAuC;IAC3C,MAAM,CAAC,OAAO,CACpB,QAAmB,EACnB,OAA4B,EAC5B,UAAkB,EAClB,YAAqB,EACrB,gBAA8C;QAE/C,OAAO,IAAI,OAAO,CAAyB,CAAC,OAAiD,EAAE,MAA2C,EAAQ,EAAE;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GhB,GAAW,EACX,IAAO,EACP,MAAgC,EAChC,OAAiC,EACjC,gBAAyC,EACzC,gBAA8C,EAC9C,OAA2C;QAE5C,OAAO,uCAAuC,CAAC,mBAAmB,CAChE,kBAAkB,CAAC,GAAG,EACtB,GAAG,EACH,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,IAAI,EACJ,gBAAgB,EAChB,OAAO,CAAC,OAAO,CACc,CAAC;IACjC,CAAC;IAEM,aAAa,CAGlB,GAAW,EACX,IAAO,EACP,MAAgC,EAChC,OAAiC,EACjC,gBAAyC,EACzC,gBAA8C,EAC9C,OAA2C;QAE5C,OAAO,uCAAuC,CAAC,mBAAmB,CAChE,kBAAkB,CAAC,KAAK,EACxB,GAAG,EACH,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,IAAI,EACJ,gBAAgB,EAChB,OAAO,CAAC,OAAO,CACc,CAAC;IACjC,CAAC;CACD"}
@@ -0,0 +1,17 @@
1
+ import { TEncodedObject } from 'tscommons-esm-core';
2
+ import { ICommonsStreamableHttpClientImplementation, TCommonsStreamableHttpObservable } from 'tscommons-esm-http';
3
+ import { THttpHeaderOrParamObject } from 'tscommons-esm-http';
4
+ import { TCommonsHttpInternalRequestOptions } from 'tscommons-esm-http';
5
+ import { ECommonsHttpContentType } from 'tscommons-esm-http';
6
+ import { ECommonsHttpResponseDataType } from 'tscommons-esm-http';
7
+ export declare class CommonsStreamableHttpClientImplementation implements ICommonsStreamableHttpClientImplementation {
8
+ private static request;
9
+ private static requestHeadGetDelete;
10
+ private static requestPostPutPatch;
11
+ internalHead(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
12
+ internalGet(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
13
+ internalDelete(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
14
+ internalPost<B extends TEncodedObject = TEncodedObject>(url: string, body: B, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
15
+ internalPut<B extends TEncodedObject = TEncodedObject>(url: string, body: B, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
16
+ internalPatch<B extends TEncodedObject = TEncodedObject>(url: string, body: B, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
17
+ }
@@ -0,0 +1,151 @@
1
+ import { URL } from 'url';
2
+ import * as https from 'https';
3
+ import * as http from 'http';
4
+ import { Subject } from 'rxjs';
5
+ import { default as formurlencoded } from 'form-urlencoded';
6
+ import { CommonsHttpTimeoutError } from 'tscommons-esm-http';
7
+ import { commonsHttpBuildErrorFromResponseCode } from 'tscommons-esm-http';
8
+ import { ECommonsHttpContentType } from 'tscommons-esm-http';
9
+ import { ECommonsHttpResponseDataType } from 'tscommons-esm-http';
10
+ import { ECommonsHttpMethod } from 'tscommons-esm-http';
11
+ import { commonsHttpAppendEncodedObjectParams } from '../helpers/commons-http-query-string.mjs';
12
+ export class CommonsStreamableHttpClientImplementation {
13
+ static request(protocol, options, bodyString, responseDataType) {
14
+ const dataSubject = new Subject();
15
+ const outcomeSubject = new Subject();
16
+ const promise = new Promise((resolve, reject) => {
17
+ let hasCompleted = false;
18
+ const complete = () => {
19
+ if (hasCompleted)
20
+ return;
21
+ try {
22
+ dataSubject.complete();
23
+ outcomeSubject.complete();
24
+ }
25
+ finally {
26
+ hasCompleted = true;
27
+ }
28
+ };
29
+ const completeOutcome = (outcome) => {
30
+ resolve(outcome);
31
+ complete();
32
+ };
33
+ const completeError = (error) => {
34
+ reject(error);
35
+ complete();
36
+ };
37
+ let timedOut = false;
38
+ const request = protocol.request(options, (res) => {
39
+ if (responseDataType === ECommonsHttpResponseDataType.STRING)
40
+ res.setEncoding('utf8');
41
+ if (options.timeout)
42
+ res.setTimeout(options.timeout);
43
+ res.on('data', (chunk) => {
44
+ if (responseDataType === ECommonsHttpResponseDataType.UINT8ARRAY) {
45
+ dataSubject.next(Buffer.from(chunk)); // eslint-disable-line @typescript-eslint/no-unsafe-argument
46
+ }
47
+ else {
48
+ dataSubject.next(chunk);
49
+ }
50
+ });
51
+ res.on('end', () => {
52
+ if (res.statusCode && res.statusCode >= 400) {
53
+ completeOutcome(commonsHttpBuildErrorFromResponseCode(res.statusCode, ''));
54
+ }
55
+ else {
56
+ completeOutcome(true);
57
+ }
58
+ });
59
+ });
60
+ request.on('error', (e) => {
61
+ // these are underpinning errors like socket errors rather than HTTP response codes (404, 500 etc.)
62
+ if (timedOut)
63
+ return; // ignore duplicate timeout error throws
64
+ completeError(e);
65
+ });
66
+ if (options.timeout) {
67
+ request.on('timeout', () => {
68
+ timedOut = true; // prevent duplicate timeout error throws
69
+ completeError(new CommonsHttpTimeoutError());
70
+ // do this after, as it might cause an error to be thrown itself
71
+ // it's a clean-up more than anything else
72
+ request.destroy();
73
+ });
74
+ request.setTimeout(options.timeout);
75
+ }
76
+ request.write(bodyString);
77
+ request.end();
78
+ });
79
+ return {
80
+ dataStream: dataSubject,
81
+ outcome: promise
82
+ };
83
+ }
84
+ static requestHeadGetDelete(method, url, params, headers, responseDataType, timeout) {
85
+ const protocol = url.match(/^https:/) ? https : http;
86
+ if (params && Object.keys(params).length > 0) {
87
+ url = commonsHttpAppendEncodedObjectParams(url, params);
88
+ }
89
+ const urlObject = new URL(url);
90
+ const options = {
91
+ protocol: urlObject.protocol,
92
+ hostname: urlObject.hostname,
93
+ port: parseInt(urlObject.port, 10),
94
+ path: urlObject.search ? `${urlObject.pathname}${urlObject.search}` : urlObject.pathname,
95
+ method: method,
96
+ headers: headers,
97
+ timeout: timeout
98
+ };
99
+ return CommonsStreamableHttpClientImplementation.request(protocol, options, '', responseDataType);
100
+ }
101
+ static requestPostPutPatch(method, url, body, contentType, params, headers, responseDataType, timeout) {
102
+ const protocol = url.match(/^https:/) ? https : http;
103
+ if (params && Object.keys(params).length > 0) {
104
+ url = commonsHttpAppendEncodedObjectParams(url, params);
105
+ }
106
+ const urlObject = new URL(url);
107
+ const options = {
108
+ protocol: urlObject.protocol,
109
+ hostname: urlObject.hostname,
110
+ port: parseInt(urlObject.port, 10),
111
+ path: urlObject.search ? `${urlObject.pathname}${urlObject.search}` : urlObject.pathname,
112
+ method: method,
113
+ headers: headers,
114
+ timeout: timeout
115
+ };
116
+ let bodyData = '';
117
+ switch (contentType) {
118
+ case ECommonsHttpContentType.JSON:
119
+ bodyData = JSON.stringify(body);
120
+ break;
121
+ case ECommonsHttpContentType.FORM_URL:
122
+ bodyData = formurlencoded(body);
123
+ break;
124
+ default:
125
+ throw new Error('Unknown encoding type');
126
+ }
127
+ // we can't do this in the tscommons-esm-http, as formurlencoded isn't used in Angular
128
+ options.headers['Content-Length'] = Buffer.byteLength(bodyData, 'utf-8').toString(10);
129
+ return this.request(protocol, options, bodyData, responseDataType);
130
+ }
131
+ internalHead(url, params, headers, options) {
132
+ return CommonsStreamableHttpClientImplementation.requestHeadGetDelete(ECommonsHttpMethod.HEAD, url, params, headers, ECommonsHttpResponseDataType.UINT8ARRAY, // na
133
+ options.timeout);
134
+ }
135
+ internalGet(url, params, headers, responseDataType, options) {
136
+ return CommonsStreamableHttpClientImplementation.requestHeadGetDelete(ECommonsHttpMethod.GET, url, params, headers, responseDataType, options.timeout);
137
+ }
138
+ internalDelete(url, params, headers, responseDataType, options) {
139
+ return CommonsStreamableHttpClientImplementation.requestHeadGetDelete(ECommonsHttpMethod.DELETE, url, params, headers, responseDataType, options.timeout);
140
+ }
141
+ internalPost(url, body, params, headers, bodyDataEncoding, responseDataType, options) {
142
+ return CommonsStreamableHttpClientImplementation.requestPostPutPatch(ECommonsHttpMethod.POST, url, body, bodyDataEncoding, params, headers, responseDataType, options.timeout);
143
+ }
144
+ internalPut(url, body, params, headers, bodyDataEncoding, responseDataType, options) {
145
+ return CommonsStreamableHttpClientImplementation.requestPostPutPatch(ECommonsHttpMethod.PUT, url, body, bodyDataEncoding, params, headers, responseDataType, options.timeout);
146
+ }
147
+ internalPatch(url, body, params, headers, bodyDataEncoding, responseDataType, options) {
148
+ return CommonsStreamableHttpClientImplementation.requestPostPutPatch(ECommonsHttpMethod.PATCH, url, body, bodyDataEncoding, params, headers, responseDataType, options.timeout);
149
+ }
150
+ }
151
+ //# sourceMappingURL=commons-streamable-http-client-implementation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-streamable-http-client-implementation.mjs","sourceRoot":"","sources":["../../src/classes/commons-streamable-http-client-implementation.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAI5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,qCAAqC,EAAE,MAAM,oBAAoB,CAAC;AAG3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBA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C,OAAiC,EACjC,gBAAyC,EACzC,gBAA8C,EAC9C,OAA2C;QAE5C,OAAO,yCAAyC,CAAC,mBAAmB,CAClE,kBAAkB,CAAC,GAAG,EACtB,GAAG,EACH,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,gBAAgB,EAChB,OAAO,CAAC,OAAO,CAChB,CAAC;IACH,CAAC;IAEM,aAAa,CAGlB,GAAW,EACX,IAAO,EACP,MAAgC,EAChC,OAAiC,EACjC,gBAAyC,EACzC,gBAA8C,EAC9C,OAA2C;QAE5C,OAAO,yCAAyC,CAAC,mBAAmB,CAClE,kBAAkB,CAAC,KAAK,EACxB,GAAG,EACH,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,gBAAgB,EAChB,OAAO,CAAC,OAAO,CAChB,CAAC;IACH,CAAC;CACD"}
@@ -0,0 +1,5 @@
1
+ export declare enum ECommonsStrictParamPlurality {
2
+ SINGLE = "single",
3
+ ARRAY = "array",
4
+ ANY = "any"
5
+ }
@@ -0,0 +1,7 @@
1
+ export var ECommonsStrictParamPlurality;
2
+ (function (ECommonsStrictParamPlurality) {
3
+ ECommonsStrictParamPlurality["SINGLE"] = "single";
4
+ ECommonsStrictParamPlurality["ARRAY"] = "array";
5
+ ECommonsStrictParamPlurality["ANY"] = "any";
6
+ })(ECommonsStrictParamPlurality || (ECommonsStrictParamPlurality = {}));
7
+ //# sourceMappingURL=ecommons-strict-param-plurality.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecommons-strict-param-plurality.mjs","sourceRoot":"","sources":["../../src/enums/ecommons-strict-param-plurality.mts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,4BAIX;AAJD,WAAY,4BAA4B;IACtC,iDAAiB,CAAA;IACjB,+CAAe,CAAA;IACf,2CAAW,CAAA;AACb,CAAC,EAJW,4BAA4B,KAA5B,4BAA4B,QAIvC"}
@@ -0,0 +1,12 @@
1
+ export declare enum ECommonsStrictParamType {
2
+ ID = "id",
3
+ IDNAME = "idname",
4
+ INT = "int",
5
+ BASE36 = "base36",
6
+ BASE62 = "base62",
7
+ BASE62LONG = "base62long",
8
+ YMD = "ymd",
9
+ YMDHIS = "ymdhis"
10
+ }
11
+ export declare function toECommonsStrictParamType(type: string): ECommonsStrictParamType | undefined;
12
+ export declare function fromECommonsStrictParamType(type: ECommonsStrictParamType): string;
@@ -0,0 +1,55 @@
1
+ export var ECommonsStrictParamType;
2
+ (function (ECommonsStrictParamType) {
3
+ ECommonsStrictParamType["ID"] = "id";
4
+ ECommonsStrictParamType["IDNAME"] = "idname";
5
+ ECommonsStrictParamType["INT"] = "int";
6
+ ECommonsStrictParamType["BASE36"] = "base36";
7
+ ECommonsStrictParamType["BASE62"] = "base62";
8
+ ECommonsStrictParamType["BASE62LONG"] = "base62long";
9
+ ECommonsStrictParamType["YMD"] = "ymd";
10
+ ECommonsStrictParamType["YMDHIS"] = "ymdhis";
11
+ })(ECommonsStrictParamType || (ECommonsStrictParamType = {}));
12
+ export function toECommonsStrictParamType(type) {
13
+ switch (type) {
14
+ case ECommonsStrictParamType.ID.toString():
15
+ return ECommonsStrictParamType.ID;
16
+ case ECommonsStrictParamType.IDNAME.toString():
17
+ return ECommonsStrictParamType.IDNAME;
18
+ case ECommonsStrictParamType.INT.toString():
19
+ return ECommonsStrictParamType.INT;
20
+ case ECommonsStrictParamType.BASE36.toString():
21
+ return ECommonsStrictParamType.BASE36;
22
+ case ECommonsStrictParamType.BASE62.toString():
23
+ return ECommonsStrictParamType.BASE62;
24
+ case ECommonsStrictParamType.BASE62LONG.toString():
25
+ return ECommonsStrictParamType.BASE62LONG;
26
+ case ECommonsStrictParamType.YMD.toString():
27
+ return ECommonsStrictParamType.YMD;
28
+ case ECommonsStrictParamType.YMDHIS.toString():
29
+ return ECommonsStrictParamType.YMDHIS;
30
+ default:
31
+ return undefined;
32
+ }
33
+ }
34
+ export function fromECommonsStrictParamType(type) {
35
+ switch (type) {
36
+ case ECommonsStrictParamType.ID:
37
+ return ECommonsStrictParamType.ID.toString();
38
+ case ECommonsStrictParamType.IDNAME:
39
+ return ECommonsStrictParamType.IDNAME.toString();
40
+ case ECommonsStrictParamType.INT:
41
+ return ECommonsStrictParamType.INT.toString();
42
+ case ECommonsStrictParamType.BASE36:
43
+ return ECommonsStrictParamType.BASE36.toString();
44
+ case ECommonsStrictParamType.BASE62:
45
+ return ECommonsStrictParamType.BASE62.toString();
46
+ case ECommonsStrictParamType.BASE62LONG:
47
+ return ECommonsStrictParamType.BASE62LONG.toString();
48
+ case ECommonsStrictParamType.YMD:
49
+ return ECommonsStrictParamType.YMD.toString();
50
+ case ECommonsStrictParamType.YMDHIS:
51
+ return ECommonsStrictParamType.YMDHIS.toString();
52
+ }
53
+ throw new Error('Unknown ECommonsStrictParamType');
54
+ }
55
+ //# sourceMappingURL=ecommons-strict-param-type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecommons-strict-param-type.mjs","sourceRoot":"","sources":["../../src/enums/ecommons-strict-param-type.mts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,uBASX;AATD,WAAY,uBAAuB;IACjC,oCAAS,CAAA;IACT,4CAAiB,CAAA;IACjB,sCAAW,CAAA;IACX,4CAAiB,CAAA;IACjB,4CAAiB,CAAA;IACjB,oDAAyB,CAAA;IACzB,sCAAW,CAAA;IACX,4CAAiB,CAAA;AACnB,CAAC,EATW,uBAAuB,KAAvB,uBAAuB,QASlC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACrD,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,uBAAuB,CAAC,EAAE,CAAC,QAAQ,EAAE;YACzC,OAAO,uBAAuB,CAAC,EAAE,CAAC;QACnC,KAAK,uBAAuB,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC7C,OAAO,uBAAuB,CAAC,MAAM,CAAC;QACvC,KAAK,uBAAuB,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC1C,OAAO,uBAAuB,CA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AC/C,KAAK,uBAAuB,CAAC,MAAM;YAClC,OAAO,uBAAuB,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACnD,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function commonsDnsResolveDomain4(domain: string, timeout: number): Promise<string[]>;
2
+ export declare function commonsDnsResolveDomain6(domain: string, timeout: number): Promise<string[]>;
3
+ export declare function commonsDnsResolveReverse(ip: string, timeout: number): Promise<string[]>;
@@ -0,0 +1,36 @@
1
+ import * as dns from 'dns';
2
+ import { commonsPromiseTimeout } from 'tscommons-esm-async';
3
+ export function commonsDnsResolveDomain4(domain, timeout) {
4
+ return commonsPromiseTimeout(async () => new Promise((resolve, reject) => {
5
+ dns.resolve4(domain, (err, address) => {
6
+ if (err) {
7
+ reject(err);
8
+ return;
9
+ }
10
+ resolve(address);
11
+ });
12
+ }), timeout);
13
+ }
14
+ export function commonsDnsResolveDomain6(domain, timeout) {
15
+ return commonsPromiseTimeout(async () => new Promise((resolve, reject) => {
16
+ dns.resolve6(domain, (err, address) => {
17
+ if (err) {
18
+ reject(err);
19
+ return;
20
+ }
21
+ resolve(address);
22
+ });
23
+ }), timeout);
24
+ }
25
+ export function commonsDnsResolveReverse(ip, timeout) {
26
+ return commonsPromiseTimeout(async () => new Promise((resolve, reject) => {
27
+ dns.reverse(ip, (err, hostnames) => {
28
+ if (err) {
29
+ reject(err);
30
+ return;
31
+ }
32
+ resolve(hostnames);
33
+ });
34
+ }), timeout);
35
+ }
36
+ //# sourceMappingURL=commons-dns.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-dns.mjs","sourceRoot":"","sources":["../../src/helpers/commons-dns.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,UAAU,wBAAwB,CAC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,CAAC;IACH,CAAC,CAAC,EACF,OAAO,CACR,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import * as querystring from 'querystring';
2
+ import { TEncodedObject } from 'tscommons-esm-core';
3
+ export declare function commonsHttpEncodedObjectToQueryInput(encoded: TEncodedObject): querystring.ParsedUrlQueryInput;
4
+ export declare function commonsHttpAppendEncodedObjectParams(url: string, params: TEncodedObject): string;
@@ -0,0 +1,39 @@
1
+ import * as querystring from 'querystring';
2
+ import { commonsTypeIsString, commonsTypeIsNumber, commonsTypeIsDate, commonsTypeIsBoolean, commonsTypeIsStringArray, commonsTypeIsNumberArray, commonsTypeIsBooleanArray, commonsDateDateToYmdHis } from 'tscommons-esm-core';
3
+ export function commonsHttpEncodedObjectToQueryInput(encoded) {
4
+ const converted = {};
5
+ for (const key of Object.keys(encoded)) {
6
+ if (encoded[key] === undefined || encoded[key] === null) {
7
+ converted[key] = '';
8
+ continue;
9
+ }
10
+ const value = encoded[key];
11
+ if (commonsTypeIsString(value)
12
+ || commonsTypeIsNumber(value)
13
+ || commonsTypeIsBoolean(value)) {
14
+ converted[key] = value;
15
+ continue;
16
+ }
17
+ if (commonsTypeIsDate(value)) {
18
+ converted[key] = commonsDateDateToYmdHis(value);
19
+ continue;
20
+ }
21
+ if (commonsTypeIsStringArray(value)
22
+ || commonsTypeIsNumberArray(value)
23
+ || commonsTypeIsBooleanArray(value)) {
24
+ converted[key] = value;
25
+ continue;
26
+ }
27
+ const type = typeof value;
28
+ throw new Error(`Unable to convert value of type ${type} in CommonsUrl.encodedObjectToQueryString`);
29
+ }
30
+ return converted;
31
+ }
32
+ export function commonsHttpAppendEncodedObjectParams(url, params) {
33
+ if (params.length === 0)
34
+ return url;
35
+ const separator = url.indexOf('?') === -1 ? '?' : '&';
36
+ const converted = commonsHttpEncodedObjectToQueryInput(params);
37
+ return `${url}${separator}${querystring.stringify(converted)}`;
38
+ }
39
+ //# sourceMappingURL=commons-http-query-string.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-http-query-string.mjs","sourceRoot":"","sources":["../../src/helpers/commons-http-query-string.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,aAAa,CAAC;AAE3C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,UAAU,oCAAoC,CAAC,OAAuB;IAC3E,MAAM,SAAS,GAAoC,EAAE,CAAC;IAEtD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;YACzD,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACpB,SAAS;QACV,CAAC;QAED,MAAM,KAAK,GAAa,OAAO,CAAC,GAAG,CAAC,CAAC;QAErC,IACC,mBAAmB,CAAC,KAAK,CAAC;eACvB,mBAAmB,CAAC,KAAK,CAAC;eAC1B,oBAAoB,CAAC,KAAK,CAAC,EAC7B,CAAC;YACF,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACvB,SAAS;QACV,CAAC;QAED,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,SAAS,CAAC,GAAG,CAAC,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;YAChD,SAAS;QACV,CAAC;QAED,IACC,wBAAwB,CAAC,KAAK,CAAC;eAC5B,wBAAwB,CAAC,KAAK,CAAC;eAC/B,yBAAyB,CAAC,KAAK,CAAC,EAClC,CAAC;YACF,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACvB,SAAS;QACV,CAAC;QAED,MAAM,IAAI,GAAW,OAAO,KAAK,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,2CAA2C,CAAC,CAAC;IACrG,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,oCAAoC,CAAC,GAAW,EAAE,MAAsB;IACvF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAEpC,MAAM,SAAS,GAAW,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAE9D,MAAM,SAAS,GAAoC,oCAAoC,CAAC,MAAM,CAAC,CAAC;IAChG,OAAO,GAAG,GAAG,GAAG,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;AAChE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { TCommonsHttpResponse } from '../types/tcommons-http-response.mjs';
2
+ export declare function commonsHttpNoCache(res: TCommonsHttpResponse): void;
3
+ export declare function commonsHttpCache(res: TCommonsHttpResponse, seconds: number): void;
4
+ export declare function commonsHttpUseCacheIfUnchanged(res: TCommonsHttpResponse): void;
5
+ export declare function commonsHttpSetLastModified(res: TCommonsHttpResponse, timestamp: Date): void;
@@ -0,0 +1,17 @@
1
+ export function commonsHttpNoCache(res) {
2
+ res.setHeader('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
3
+ res.setHeader('Expires', '-1');
4
+ res.setHeader('Pragma', 'no-cache');
5
+ }
6
+ export function commonsHttpCache(res, seconds) {
7
+ res.setHeader('Cache-Control', `public, max-age=${seconds}`);
8
+ }
9
+ export function commonsHttpUseCacheIfUnchanged(res) {
10
+ // see "Requiring revalidation": https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
11
+ // Makes browsers check for a new version, but not download if it isn't changed
12
+ res.setHeader('Cache-Control', 'no-cache, max-age=0');
13
+ }
14
+ export function commonsHttpSetLastModified(res, timestamp) {
15
+ res.setHeader('Last-Modified', timestamp.toUTCString());
16
+ }
17
+ //# sourceMappingURL=commons-http-response.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-http-response.mjs","sourceRoot":"","sources":["../../src/helpers/commons-http-response.mts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,GAAyB;IAC3D,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,sFAAsF,CAAC,CAAC;IACvH,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/B,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAyB,EAAE,OAAe;IAC1E,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,mBAAmB,OAAO,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,GAAyB;IACvE,wGAAwG;IACxG,+EAA+E;IAC/E,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,GAAyB,EAAE,SAAe;IACpF,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function commonsNginxProxyPath(p?: string): string;
@@ -0,0 +1,6 @@
1
+ export function commonsNginxProxyPath(p) {
2
+ if (p === undefined)
3
+ return '/';
4
+ return `${p}${p.endsWith('/') ? '' : '/'}`;
5
+ }
6
+ //# sourceMappingURL=commons-nginx-proxy-path.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-nginx-proxy-path.mjs","sourceRoot":"","sources":["../../src/helpers/commons-nginx-proxy-path.mts"],"names":[],"mappings":"AAAA,MAAM,UAAU,qBAAqB,CAAC,CAAU;IAC/C,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IAChC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { TPropertyObject } from 'tscommons-esm-core';
2
+ export declare function commonsSslGetCertificate(domain: string, timeout: number, port?: number): Promise<TPropertyObject | null>;
@@ -0,0 +1,22 @@
1
+ import * as https from 'https';
2
+ import { commonsPromiseTimeout } from 'tscommons-esm-async';
3
+ export function commonsSslGetCertificate(domain, timeout, port = 443) {
4
+ return commonsPromiseTimeout(async () => new Promise((resolve, reject) => {
5
+ const request = https.request({
6
+ hostname: domain,
7
+ port: port,
8
+ method: 'GET',
9
+ timeout: timeout,
10
+ rejectUnauthorized: true,
11
+ agent: false
12
+ }, (result) => {
13
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
14
+ resolve(result.socket.getPeerCertificate());
15
+ });
16
+ request.on('error', (e) => {
17
+ reject(e);
18
+ });
19
+ request.end();
20
+ }), timeout);
21
+ }
22
+ //# sourceMappingURL=commons-ssl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-ssl.mjs","sourceRoot":"","sources":["../../src/helpers/commons-ssl.mts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,MAAM,UAAU,wBAAwB,CACtC,MAAc,EACd,OAAe,EACf,OAAe,GAAG;IAEnB,OAAO,qBAAqB,CAC1B,KAAK,IAAmC,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAoD,EAAE,MAA0B,EAAQ,EAAE;QACjJ,MAAM,OAAO,GAAkB,KAAK,CAAC,OAAO,CAC1C;YACE,QAAQ,EAAE,MAAM;YAChB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,OAAO;YAChB,kBAAkB,EAAE,IAAI;YACxB,KAAK,EAAE,KAAK;SAEb,EACD,CAAC,MAAuB,EAAQ,EAAE;YACjC,gJAAgJ;YAChJ,OAAO,CAAE,MAAM,CAAC,MAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC;QACtD,CAAC,CACF,CAAC;QACF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAQ,EAAQ,EAAE;YACtC,MAAM,CAAC,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,EAAE,CAAC;IACf,CAAC,CAAC,EACF,OAAO,CACR,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { TPropertyObject } from 'tscommons-esm-core';
2
+ import { ECommonsStrictParamPlurality } from '../enums/ecommons-strict-param-plurality.mjs';
3
+ import { ECommonsStrictParamType } from '../enums/ecommons-strict-param-type.mjs';
4
+ import { TCommonsStrictParamResult } from '../types/tcommons-strict-param-result.mjs';
5
+ import { TCommonsHttpStrictParam } from '../types/tcommons-strict-param.mjs';
6
+ import { TCommonsStrictParamPropertyObject } from '../types/tcommons-strict-param-property-object.mjs';
7
+ export declare const COMMONS_HTTP_STRICT_PARAM_TYPE_REGEX: RegExp;
8
+ export declare function commonsRemoveStrictsFromPathDefinition(p: string): string;
9
+ export declare function commonsBuildStrictsFromPathDefinition(definedPath: string): TCommonsHttpStrictParam[];
10
+ export declare function commonsValueToStrictParamResult(value: string, type: ECommonsStrictParamType, plurality: ECommonsStrictParamPlurality, options?: string[]): TCommonsStrictParamResult | TCommonsStrictParamResult[] | undefined;
11
+ export declare function commonsExtractStrictParamsFromUrlPath(definedPath: string, suppliedUrlPath: string): [TPropertyObject<string>, TCommonsStrictParamPropertyObject] | false;
@@ -0,0 +1,165 @@
1
+ import { COMMONS_REGEX_PATTERN_BASE36_ID, COMMONS_REGEX_PATTERN_BASE62_ID, COMMONS_REGEX_PATTERN_BASE62_LONG_ID, COMMONS_REGEX_PATTERN_DATETIME_YMDHIS, COMMONS_REGEX_PATTERN_DATE_YMD, COMMONS_REGEX_PATTERN_ID, COMMONS_REGEX_PATTERN_ID_NAME, commonsDateYmdHisToDate, commonsDateYmdToDate, commonsTypeAttemptNumber, commonsTypeIsArray } from 'tscommons-esm-core';
2
+ import { ECommonsStrictParamPlurality } from '../enums/ecommons-strict-param-plurality.mjs';
3
+ import { ECommonsStrictParamType, toECommonsStrictParamType } from '../enums/ecommons-strict-param-type.mjs';
4
+ export const COMMONS_HTTP_STRICT_PARAM_TYPE_REGEX = /^:([-_a-z0-9]+)(?:(?:\[(id|idname|int|base36|base62|base62long|ymd|ymdhis)([*+])?\])|(?:\(([-a-z0-9]{1,32}(?:\|[-a-z0-9]{1,32})+)\)))?([^-a-z0-9].*)?$/i;
5
+ export function commonsRemoveStrictsFromPathDefinition(p) {
6
+ return p
7
+ .split('/')
8
+ .map((part) => {
9
+ const result = COMMONS_HTTP_STRICT_PARAM_TYPE_REGEX.exec(part);
10
+ if (result === null)
11
+ return part;
12
+ return `:${result[1]}${result[5] || ''}`;
13
+ })
14
+ .join('/');
15
+ }
16
+ export function commonsBuildStrictsFromPathDefinition(definedPath) {
17
+ return definedPath
18
+ .split('/')
19
+ .filter((param) => COMMONS_HTTP_STRICT_PARAM_TYPE_REGEX.test(param))
20
+ .map((param) => {
21
+ const match = COMMONS_HTTP_STRICT_PARAM_TYPE_REGEX.exec(param);
22
+ if (match === null)
23
+ throw new Error('Should not be possible');
24
+ const strict = {
25
+ variable: match[1],
26
+ plurality: ECommonsStrictParamPlurality.SINGLE
27
+ };
28
+ if (match[4] !== undefined) {
29
+ strict.type = ECommonsStrictParamType.IDNAME;
30
+ strict.options = match[4].split('|');
31
+ }
32
+ else {
33
+ if (match[2] !== undefined)
34
+ strict.type = toECommonsStrictParamType(match[2]);
35
+ if (match[3] !== undefined) {
36
+ switch (match[3]) {
37
+ case '+':
38
+ strict.plurality = ECommonsStrictParamPlurality.ARRAY;
39
+ break;
40
+ }
41
+ switch (match[3]) {
42
+ case '*':
43
+ strict.plurality = ECommonsStrictParamPlurality.ANY;
44
+ break;
45
+ }
46
+ }
47
+ }
48
+ return strict;
49
+ });
50
+ }
51
+ export function commonsValueToStrictParamResult(value, type, plurality, options) {
52
+ if (plurality === ECommonsStrictParamPlurality.ARRAY
53
+ || (plurality === ECommonsStrictParamPlurality.ANY && value.indexOf(',') > -1)) {
54
+ const items = value.split(',')
55
+ // allow trailing comma to differentiate single item arrays from singular types
56
+ .map((item) => item.trim())
57
+ .filter((item) => item !== '')
58
+ .map((item) => commonsValueToStrictParamResult(item, type, ECommonsStrictParamPlurality.SINGLE, options)); // can't be recursively array, as the plurality is fixed at single
59
+ if (items
60
+ .filter((item) => item === undefined)
61
+ .length > 0)
62
+ return undefined;
63
+ return items
64
+ .map((item) => item);
65
+ }
66
+ switch (type) {
67
+ case ECommonsStrictParamType.ID: {
68
+ if (!COMMONS_REGEX_PATTERN_ID.test(value))
69
+ return undefined;
70
+ const id = commonsTypeAttemptNumber(value);
71
+ if (id === undefined || id < 1)
72
+ return undefined;
73
+ return id;
74
+ }
75
+ case ECommonsStrictParamType.IDNAME: {
76
+ if (!COMMONS_REGEX_PATTERN_ID_NAME.test(value))
77
+ return undefined;
78
+ if (options && !options.includes(value))
79
+ return undefined;
80
+ return value;
81
+ }
82
+ case ECommonsStrictParamType.INT: {
83
+ const int = commonsTypeAttemptNumber(value);
84
+ if (int === undefined)
85
+ return undefined;
86
+ return int;
87
+ }
88
+ case ECommonsStrictParamType.BASE36: {
89
+ if (!COMMONS_REGEX_PATTERN_BASE36_ID.test(value))
90
+ return undefined;
91
+ return value;
92
+ }
93
+ case ECommonsStrictParamType.BASE62: {
94
+ if (!COMMONS_REGEX_PATTERN_BASE62_ID.test(value))
95
+ return undefined;
96
+ return value;
97
+ }
98
+ case ECommonsStrictParamType.BASE62LONG: {
99
+ if (!COMMONS_REGEX_PATTERN_BASE62_LONG_ID.test(value))
100
+ return undefined;
101
+ return value;
102
+ }
103
+ case ECommonsStrictParamType.YMD: {
104
+ if (!COMMONS_REGEX_PATTERN_DATE_YMD.test(value))
105
+ return undefined;
106
+ return commonsDateYmdToDate(value);
107
+ }
108
+ case ECommonsStrictParamType.YMDHIS: {
109
+ if (!COMMONS_REGEX_PATTERN_DATETIME_YMDHIS.test(value))
110
+ return undefined;
111
+ return commonsDateYmdHisToDate(value);
112
+ }
113
+ default:
114
+ throw new Error('Unknown parameter type');
115
+ }
116
+ }
117
+ // NB this isn't actually used by the express server. It is used by other pseudo ones like the socket io one.
118
+ export function commonsExtractStrictParamsFromUrlPath(definedPath, suppliedUrlPath) {
119
+ const definedParts = commonsRemoveStrictsFromPathDefinition(definedPath).split('/');
120
+ const stricts = commonsBuildStrictsFromPathDefinition(definedPath);
121
+ const suppliedParts = suppliedUrlPath.split('/');
122
+ if (definedParts.length !== suppliedParts.length)
123
+ return false;
124
+ const params = {};
125
+ const strictParams = {};
126
+ for (let i = 0; i < definedParts.length; i++) {
127
+ const d = definedParts[i];
128
+ const s = suppliedParts[i];
129
+ if (!d.startsWith(':')) {
130
+ if (d !== s)
131
+ return false;
132
+ continue;
133
+ }
134
+ const match = stricts
135
+ .find((strict) => strict.variable === d.substring(1));
136
+ if (!match)
137
+ return false;
138
+ params[match.variable] = s;
139
+ if (!match.type) {
140
+ // no type defined, so always assume matches
141
+ }
142
+ else {
143
+ const strictResult = commonsValueToStrictParamResult(s, match.type, match.plurality, match.options);
144
+ if (!strictResult)
145
+ return false;
146
+ if (match.plurality === ECommonsStrictParamPlurality.ARRAY && !commonsTypeIsArray(strictResult))
147
+ return false;
148
+ if (match.plurality === ECommonsStrictParamPlurality.SINGLE && commonsTypeIsArray(strictResult))
149
+ return false;
150
+ strictParams[match.variable] = strictResult;
151
+ }
152
+ }
153
+ return [params, strictParams];
154
+ }
155
+ // const test1: string = '/tests/:test1/values/like/:test2[id]/:test3[base62]/test4/:test5/:test6(a|b|c)/so-as/:test7[ymdhis*]';
156
+ // console.log(removeStrictsFromPathDefinition(test1));
157
+ // const testYes1: string = '/tests/t1/values/like/123/abcd1234/test4/99-z/c/so-as/2023-08-01 10:00:00,2023-08-01 11:00:00,2023-08-01 12:00:00';
158
+ // console.log('testYes1', matchesPath(test1, testYes1));
159
+ // const testNo1: string = '/tests/t1/value/like/123/abcd1234/test4/99-z/c/so-as/2023-08-01 10:00:00,2023-08-01 11:00:00,2023-08-01 12:00:00';
160
+ // console.log('testNo1', matchesPath(test1, testNo1));
161
+ // const testNo2: string = '/tests/t1/values/like/123/bcd1234/test4/99-z/c/so-as/2023-08-01 10:00:00,2023-08-01 11:00:00,2023-08-01 12:00:00';
162
+ // console.log('testNo2', matchesPath(test1, testNo2));
163
+ // const testYes2: string = '/tests/t1/values/like/123/abcd1234/test4/99-z/a/so-as/2023-08-01 10:00:00';
164
+ // console.log('testYes2', matchesPath(test1, testYes2));
165
+ //# sourceMappingURL=commons-strict-params.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-strict-params.mjs","sourceRoot":"","sources":["../../src/helpers/commons-strict-params.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,EAC/B,oCAAoC,EACpC,qCAAqC,EACrC,8BAA8B,EAC9B,wBAAwB,EACxB,6BAA6B,EAE7B,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAK7G,MAAM,CAAC,MAAM,oCAAoC,GAAW,yJAAyJ,CAAC;AAEtN,MAAM,UAAU,sCAAsC,CAAC,CAAS;IAC/D,OAAO,CAAC;SACL,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CA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HttpInternalRequestOptions } from 'tscommons-esm-http';
3
+ export declare function commonsHttpReadUrlAsBuffer(url: string, options?: TCommonsHttpInternalRequestOptions, headers?: TEncodedObject): Promise<Buffer>;
4
+ export declare function commonsHttpReadUrlAsString(url: string, options?: TCommonsHttpInternalRequestOptions, headers?: TEncodedObject): Promise<string>;
5
+ export declare function commonsHttpReadUrlAsJsonWithoutNulls(url: string, options?: TCommonsHttpInternalRequestOptions, headers?: TEncodedObject): Promise<TPropertyObject>;
@@ -0,0 +1,30 @@
1
+ // this an simple replacement implementation of the deprecated nodecommons-url
2
+ import { commonsObjectStripNulls, commonsTypeIsObject } from 'tscommons-esm-core';
3
+ import { CommonsHttpClientService } from 'tscommons-esm-http';
4
+ import { ECommonsHttpResponseDataType } from 'tscommons-esm-http';
5
+ import { CommonsInternalHttpClientImplementation } from '../classes/commons-internal-http-client-implementation.mjs';
6
+ export async function commonsHttpReadUrlAsBuffer(url, options, headers) {
7
+ const implementation = new CommonsInternalHttpClientImplementation();
8
+ const service = new CommonsHttpClientService(implementation);
9
+ const uint8Array = await service.get(url, undefined, headers, {
10
+ ...options,
11
+ responseDataType: ECommonsHttpResponseDataType.UINT8ARRAY
12
+ });
13
+ return Buffer.from(uint8Array);
14
+ }
15
+ export async function commonsHttpReadUrlAsString(url, options, headers) {
16
+ const implementation = new CommonsInternalHttpClientImplementation();
17
+ const service = new CommonsHttpClientService(implementation);
18
+ return service.get(url, undefined, headers, {
19
+ ...options,
20
+ responseDataType: ECommonsHttpResponseDataType.STRING
21
+ });
22
+ }
23
+ export async function commonsHttpReadUrlAsJsonWithoutNulls(url, options, headers) {
24
+ const raw = await commonsHttpReadUrlAsString(url, options, headers);
25
+ const json = JSON.parse(raw);
26
+ if (!commonsTypeIsObject(json))
27
+ throw new Error('Url read result was not parsed to an object');
28
+ return commonsObjectStripNulls(json);
29
+ }
30
+ //# sourceMappingURL=commons-url.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-url.mjs","sourceRo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MAAM,IAAI,GAAY,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAE/F,OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { commonsDnsResolveDomain4, commonsDnsResolveDomain6, commonsDnsResolveReverse } from './helpers/commons-dns.mjs';
2
+ import { commonsNginxProxyPath } from './helpers/commons-nginx-proxy-path.mjs';
3
+ import { commonsHttpEncodedObjectToQueryInput, commonsHttpAppendEncodedObjectParams } from './helpers/commons-http-query-string.mjs';
4
+ import { commonsSslGetCertificate } from './helpers/commons-ssl.mjs';
5
+ import { COMMONS_HTTP_STRICT_PARAM_TYPE_REGEX, commonsRemoveStrictsFromPathDefinition, commonsBuildStrictsFromPathDefinition, commonsValueToStrictParamResult, commonsExtractStrictParamsFromUrlPath } from './helpers/commons-strict-params.mjs';
6
+ import { commonsHttpNoCache, commonsHttpCache, commonsHttpUseCacheIfUnchanged, commonsHttpSetLastModified } from './helpers/commons-http-response.mjs';
7
+ import { commonsHttpReadUrlAsBuffer, commonsHttpReadUrlAsString, commonsHttpReadUrlAsJsonWithoutNulls } from './helpers/commons-url.mjs';
8
+ import { CommonsInternalHttpClientImplementation } from './classes/commons-internal-http-client-implementation.mjs';
9
+ import { CommonsStreamableHttpClientImplementation } from './classes/commons-streamable-http-client-implementation.mjs';
10
+ import { ECommonsStrictParamPlurality } from './enums/ecommons-strict-param-plurality.mjs';
11
+ import { ECommonsStrictParamType, toECommonsStrictParamType, fromECommonsStrictParamType } from './enums/ecommons-strict-param-type.mjs';
12
+ import { TCommonsHttpRequest } from './types/tcommons-http-request.mjs';
13
+ import { TCommonsHttpStrictParam } from './types/tcommons-strict-param.mjs';
14
+ import { TCommonsHttpHandler } from './types/tcommons-http-handler.mjs';
15
+ import { TCommonsStrictParamPropertyObject } from './types/tcommons-strict-param-property-object.mjs';
16
+ import { TCommonsHttpResponse } from './types/tcommons-http-response.mjs';
17
+ import { TCommonsStrictParamResult } from './types/tcommons-strict-param-result.mjs';
18
+ import { CommonsStrictHttpServer } from './interfaces/commons-http-server.mjs';
19
+ import { ICommonsHttpConfig, isICommonsHttpConfig } from './interfaces/icommons-http-config.mjs';
20
+ import { ICommonsRequestWithGetMethodTypecast, ICommonsRequestWithBodyTypecast, ICommonsRequestWithQueryTypecast } from './interfaces/hacks.mjs';
21
+ import { ICommonsStrictParamsRequest } from './interfaces/icommons-strict-params-request.mjs';
22
+ export { commonsDnsResolveDomain4, commonsDnsResolveDomain6, commonsDnsResolveReverse, commonsNginxProxyPath, commonsHttpEncodedObjectToQueryInput, commonsHttpAppendEncodedObjectParams, commonsSslGetCertificate, COMMONS_HTTP_STRICT_PARAM_TYPE_REGEX, commonsRemoveStrictsFromPathDefinition, commonsBuildStrictsFromPathDefinition, commonsValueToStrictParamResult, commonsExtractStrictParamsFromUrlPath, commonsHttpNoCache, commonsHttpCache, commonsHttpUseCacheIfUnchanged, commonsHttpSetLastModified, commonsHttpReadUrlAsBuffer, commonsHttpReadUrlAsString, commonsHttpReadUrlAsJsonWithoutNulls, CommonsInternalHttpClientImplementation, CommonsStreamableHttpClientImplementation, ECommonsStrictParamPlurality, ECommonsStrictParamType, toECommonsStrictParamType, fromECommonsStrictParamType, TCommonsHttpRequest, TCommonsHttpStrictParam, TCommonsHttpHandler, TCommonsStrictParamPropertyObject, TCommonsHttpResponse, TCommonsStrictParamResult, CommonsStrictHttpServer, ICommonsHttpConfig, isICommonsHttpConfig, ICommonsRequestWithGetMethodTypecast, ICommonsRequestWithBodyTypecast, ICommonsRequestWithQueryTypecast, ICommonsStrictParamsRequest };
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { commonsDnsResolveDomain4, commonsDnsResolveDomain6, commonsDnsResolveReverse } from './helpers/commons-dns.mjs';
2
+ import { commonsNginxProxyPath } from './helpers/commons-nginx-proxy-path.mjs';
3
+ import { commonsHttpEncodedObjectToQueryInput, commonsHttpAppendEncodedObjectParams } from './helpers/commons-http-query-string.mjs';
4
+ import { commonsSslGetCertificate } from './helpers/commons-ssl.mjs';
5
+ import { COMMONS_HTTP_STRICT_PARAM_TYPE_REGEX, commonsRemoveStrictsFromPathDefinition, commonsBuildStrictsFromPathDefinition, commonsValueToStrictParamResult, commonsExtractStrictParamsFromUrlPath } from './helpers/commons-strict-params.mjs';
6
+ import { commonsHttpNoCache, commonsHttpCache, commonsHttpUseCacheIfUnchanged, commonsHttpSetLastModified } from './helpers/commons-http-response.mjs';
7
+ import { commonsHttpReadUrlAsBuffer, commonsHttpReadUrlAsString, commonsHttpReadUrlAsJsonWithoutNulls } from './helpers/commons-url.mjs';
8
+ import { CommonsInternalHttpClientImplementation } from './classes/commons-internal-http-client-implementation.mjs';
9
+ import { CommonsStreamableHttpClientImplementation } from './classes/commons-streamable-http-client-implementation.mjs';
10
+ import { ECommonsStrictParamPlurality } from './enums/ecommons-strict-param-plurality.mjs';
11
+ import { ECommonsStrictParamType, toECommonsStrictParamType, fromECommonsStrictParamType } from './enums/ecommons-strict-param-type.mjs';
12
+ import { isICommonsHttpConfig } from './interfaces/icommons-http-config.mjs';
13
+ export { commonsDnsResolveDomain4, commonsDnsResolveDomain6, commonsDnsResolveReverse, commonsNginxProxyPath, commonsHttpEncodedObjectToQueryInput, commonsHttpAppendEncodedObjectParams, commonsSslGetCertificate, COMMONS_HTTP_STRICT_PARAM_TYPE_REGEX, commonsRemoveStrictsFromPathDefinition, commonsBuildStrictsFromPathDefinition, commonsValueToStrictParamResult, commonsExtractStrictParamsFromUrlPath, commonsHttpNoCache, commonsHttpCache, commonsHttpUseCacheIfUnchanged, commonsHttpSetLastModified, commonsHttpReadUrlAsBuffer, commonsHttpReadUrlAsString, commonsHttpReadUrlAsJsonWithoutNulls, CommonsInternalHttpClientImplementation, CommonsStreamableHttpClientImplementation, ECommonsStrictParamPlurality, ECommonsStrictParamType, toECommonsStrictParamType, fromECommonsStrictParamType, isICommonsHttpConfig };
14
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACzH,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,oCAAoC,EAAE,oCAAoC,EAAE,MAAM,yCAAyC,CAAC;AACrI,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,oCAAoC,EACpC,sCAAsC,EACtC,qCAAqC,EACrC,+BAA+B,EAC/B,qCAAqC,EACtC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,8BAA8B,EAC9B,0BAA0B,EAC3B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,oCAAoC,EAAE,MAAM,2BAA2B,CAAC;AACzI,OAAO,EAAE,uCAAuC,EAAE,MAAM,2DAA2D,CAAC;AACpH,OAAO,EAAE,yCAAyC,EAAE,MAAM,6DAA6D,CAAC;AACxH,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAQzI,OAAO,EAAsB,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAGjG,OAAO,EACN,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,oCAAoC,EACpC,oCAAoC,EACpC,wBAAwB,EACxB,oCAAoC,EACpC,sCAAsC,EACtC,qCAAqC,EACrC,+BAA+B,EAC/B,qCAAqC,EACrC,kBAAkB,EAClB,gBAAgB,EAChB,8BAA8B,EAC9B,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,oCAAoC,EACpC,uCAAuC,EACvC,yCAAyC,EACzC,4BAA4B,EAC5B,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,EAS3B,oBAAoB,EAKpB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { TCommonsHttpHandler } from '../types/tcommons-http-handler.mjs';
2
+ import { TCommonsHttpResponse } from '../types/tcommons-http-response.mjs';
3
+ import { ICommonsStrictParamsRequest } from './icommons-strict-params-request.mjs';
4
+ export interface CommonsStrictHttpServer<RequestT extends ICommonsStrictParamsRequest, ResponseT extends TCommonsHttpResponse> {
5
+ head(query: string, handler: TCommonsHttpHandler<RequestT, ResponseT>): void;
6
+ get(query: string, handler: TCommonsHttpHandler<RequestT, ResponseT>): void;
7
+ post(query: string, handler: TCommonsHttpHandler<RequestT, ResponseT>): void;
8
+ put(query: string, handler: TCommonsHttpHandler<RequestT, ResponseT>): void;
9
+ patch(query: string, handler: TCommonsHttpHandler<RequestT, ResponseT>): void;
10
+ delete(query: string, handler: TCommonsHttpHandler<RequestT, ResponseT>): void;
11
+ init(): void;
12
+ listen(): Promise<void>;
13
+ close(): void;
14
+ }
@@ -0,0 +1,3 @@
1
+ // This is a true interface
2
+ export {};
3
+ //# sourceMappingURL=commons-http-server.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-http-server.mjs","sourceRoot":"","sources":["../../src/interfaces/commons-http-server.mts"],"names":[],"mappings":"AAAA,2BAA2B"}
@@ -0,0 +1,13 @@
1
+ export interface ICommonsRequestWithGetMethodTypecast {
2
+ get(field: string): string | undefined;
3
+ }
4
+ export interface ICommonsRequestWithBodyTypecast {
5
+ body: {
6
+ [field: string]: string | number | boolean | null;
7
+ };
8
+ }
9
+ export interface ICommonsRequestWithQueryTypecast {
10
+ query: {
11
+ [field: string]: string | number | boolean;
12
+ };
13
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=hacks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hacks.mjs","sourceRoot":"","sources":["../../src/interfaces/hacks.mts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export interface ICommonsHttpConfig {
2
+ port: number;
3
+ path?: string;
4
+ }
5
+ export declare function isICommonsHttpConfig(test: any): test is ICommonsHttpConfig;
@@ -0,0 +1,9 @@
1
+ import { commonsTypeHasPropertyNumber, commonsTypeHasPropertyStringOrUndefined } from 'tscommons-esm-core';
2
+ export function isICommonsHttpConfig(test) {
3
+ if (!commonsTypeHasPropertyNumber(test, 'port'))
4
+ return false;
5
+ if (!commonsTypeHasPropertyStringOrUndefined(test, 'path'))
6
+ return false;
7
+ return true;
8
+ }
9
+ //# sourceMappingURL=icommons-http-config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icommons-http-config.mjs","sourceRoot":"","sources":["../../src/interfaces/icommons-http-config.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,uCAAuC,EAAE,MAAM,oBAAoB,CAAC;AAO3G,MAAM,UAAU,oBAAoB,CAAC,IAAS;IAC7C,IAAI,CAAC,4BAA4B,CAAC,IAAI,EAAE,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9D,IAAI,CAAC,uCAAuC,CAAC,IAAI,EAAE,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAEzE,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { TCommonsStrictParamPropertyObject } from '../types/tcommons-strict-param-property-object.mjs';
2
+ export interface ICommonsStrictParamsRequest {
3
+ strictParams: TCommonsStrictParamPropertyObject;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=icommons-strict-params-request.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icommons-strict-params-request.mjs","sourceRoot":"","sources":["../../src/interfaces/icommons-strict-params-request.mts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { ICommonsStrictParamsRequest } from '../interfaces/icommons-strict-params-request.mjs';
2
+ import { TCommonsHttpResponse } from './tcommons-http-response.mjs';
3
+ export type TCommonsHttpHandler<RequestT extends ICommonsStrictParamsRequest, ResponseT extends TCommonsHttpResponse> = (request: RequestT, response: ResponseT) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tcommons-http-handler.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcommons-http-handler.mjs","sourceRoot":"","sources":["../../src/types/tcommons-http-handler.mts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { ECommonsHttpMethod } from 'tscommons-esm-http';
2
+ import { THttpHeaderOrParamObject } from 'tscommons-esm-http';
3
+ export type TCommonsHttpRequest = {
4
+ protocol: string;
5
+ hostname: string;
6
+ port: number;
7
+ path: string;
8
+ method: ECommonsHttpMethod;
9
+ headers: THttpHeaderOrParamObject;
10
+ timeout?: number;
11
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tcommons-http-request.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcommons-http-request.mjs","sourceRoot":"","sources":["../../src/types/tcommons-http-request.mts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export type TCommonsHttpResponse = {
2
+ setHeader(key: string, value: string): any;
3
+ status(statusCode: number): any;
4
+ send(body?: string | number | boolean | object | Buffer): any;
5
+ };
@@ -0,0 +1,3 @@
1
+ // This is used as a pseudo for things like express.Response
2
+ export {};
3
+ //# sourceMappingURL=tcommons-http-response.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcommons-http-response.mjs","sourceRoot":"","sources":["../../src/types/tcommons-http-response.mts"],"names":[],"mappings":"AAAA,4DAA4D"}
@@ -0,0 +1,4 @@
1
+ import { TCommonsStrictParamResult } from './tcommons-strict-param-result.mjs';
2
+ export type TCommonsStrictParamPropertyObject = {
3
+ [name: string]: TCommonsStrictParamResult | TCommonsStrictParamResult[];
4
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tcommons-strict-param-property-object.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcommons-strict-param-property-object.mjs","sourceRoot":"","sources":["../../src/types/tcommons-strict-param-property-object.mts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export type TCommonsStrictParamResult = number | string | Date;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tcommons-strict-param-result.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcommons-strict-param-result.mjs","sourceRoot":"","sources":["../../src/types/tcommons-strict-param-result.mts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { ECommonsStrictParamPlurality } from '../enums/ecommons-strict-param-plurality.mjs';
2
+ import { ECommonsStrictParamType } from '../enums/ecommons-strict-param-type.mjs';
3
+ export type TCommonsHttpStrictParam = {
4
+ variable: string;
5
+ type?: ECommonsStrictParamType;
6
+ plurality: ECommonsStrictParamPlurality;
7
+ options?: string[];
8
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tcommons-strict-param.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcommons-strict-param.mjs","sourceRoot":"","sources":["../../src/types/tcommons-strict-param.mts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "nodecommons-esm-http",
3
+ "version": "0.0.2",
4
+ "description": "",
5
+ "scripts": {
6
+ "tsc": "./node_modules/typescript/bin/tsc",
7
+ "preprepare": "rm -rf ./dist; php ~/Dev/etim.php src/ && npm run tsc",
8
+ "publish-major": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version major && npm install && npm publish && git add . && git commit -m 'publish'",
9
+ "publish-minor": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version minor && npm install && npm publish && git add . && git commit -m 'publish'",
10
+ "publish-patch": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version patch && npm install && npm publish && git add . && git commit -m 'publish'"
11
+ },
12
+ "main": "dist/index.mjs",
13
+ "types": "dist/index.d.mjs",
14
+ "type": "module",
15
+ "author": "Pete Morris",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "@stylistic/eslint-plugin-ts": "^2.10.1",
19
+ "@types/node": "^22.9.0",
20
+ "eslint-plugin-import": "^2.31.0",
21
+ "eslint-plugin-prefer-arrow-functions": "^3.4.1",
22
+ "typescript": "^5.6.3",
23
+ "typescript-eslint": "^8.14.0"
24
+ },
25
+ "files": [
26
+ "dist/**/*"
27
+ ],
28
+ "dependencies": {
29
+ "form-urlencoded": "^6.1.5",
30
+ "tscommons-esm-async": "^0.0.2",
31
+ "tscommons-esm-core": "^0.0.2",
32
+ "tscommons-esm-http": "^0.0.3"
33
+ }
34
+ }