@leyyo/http-mock 1.3.2 → 1.3.4

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 (60) hide show
  1. package/README.md +3 -394
  2. package/dist/application/index.d.ts +1 -1
  3. package/dist/application/index.js +1 -18
  4. package/dist/application/index.types.js +1 -3
  5. package/dist/application/mock-application.d.ts +2 -2
  6. package/dist/application/mock-application.js +25 -13
  7. package/dist/enum/http-method.js +1 -5
  8. package/dist/enum/http-protocol.js +1 -5
  9. package/dist/enum/index.d.ts +2 -2
  10. package/dist/enum/index.js +2 -19
  11. package/dist/event/http-event.js +17 -36
  12. package/dist/event/index.d.ts +2 -2
  13. package/dist/event/index.js +2 -19
  14. package/dist/event/index.types.js +1 -3
  15. package/dist/http-mock.d.ts +1 -1
  16. package/dist/http-mock.js +15 -16
  17. package/dist/index.d.ts +8 -7
  18. package/dist/index.foretell.d.ts +1 -0
  19. package/dist/index.foretell.js +19 -0
  20. package/dist/index.js +8 -24
  21. package/dist/{loader.d.ts → index.loader.d.ts} +0 -1
  22. package/dist/index.loader.js +10 -0
  23. package/dist/index.types.d.ts +2 -2
  24. package/dist/index.types.js +1 -3
  25. package/dist/internal.d.ts +1 -1
  26. package/dist/internal.js +2 -6
  27. package/dist/request/index.d.ts +2 -2
  28. package/dist/request/index.js +2 -19
  29. package/dist/request/index.types.d.ts +3 -3
  30. package/dist/request/index.types.js +1 -3
  31. package/dist/request/mock.request.d.ts +3 -3
  32. package/dist/request/mock.request.js +135 -37
  33. package/dist/response/index-types.d.ts +1 -1
  34. package/dist/response/index-types.js +1 -3
  35. package/dist/response/index.d.ts +2 -2
  36. package/dist/response/index.js +2 -19
  37. package/dist/response/mock-response.d.ts +2 -2
  38. package/dist/response/mock-response.js +98 -46
  39. package/package.json +6 -5
  40. package/dist/application/index.js.map +0 -1
  41. package/dist/application/index.types.js.map +0 -1
  42. package/dist/application/mock-application.js.map +0 -1
  43. package/dist/enum/http-method.js.map +0 -1
  44. package/dist/enum/http-protocol.js.map +0 -1
  45. package/dist/enum/index.js.map +0 -1
  46. package/dist/event/http-event.js.map +0 -1
  47. package/dist/event/index.js.map +0 -1
  48. package/dist/event/index.types.js.map +0 -1
  49. package/dist/http-mock.js.map +0 -1
  50. package/dist/index.js.map +0 -1
  51. package/dist/index.types.js.map +0 -1
  52. package/dist/internal.js.map +0 -1
  53. package/dist/loader.js +0 -64
  54. package/dist/loader.js.map +0 -1
  55. package/dist/request/index.js.map +0 -1
  56. package/dist/request/index.types.js.map +0 -1
  57. package/dist/request/mock.request.js.map +0 -1
  58. package/dist/response/index-types.js.map +0 -1
  59. package/dist/response/index.js.map +0 -1
  60. package/dist/response/mock-response.js.map +0 -1
@@ -1,19 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
18
- __exportStar(require("./http-event"), exports);
19
- //# sourceMappingURL=index.js.map
1
+ export * from './index.types.js';
2
+ export * from './http-event.js';
@@ -1,3 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.types.js.map
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { HttpMockLike } from "./index.types";
1
+ import { HttpMockLike } from "./index.types.js";
2
2
  /**
3
3
  * Http mock instance
4
4
  *
package/dist/http-mock.js CHANGED
@@ -1,33 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.httpMock = void 0;
4
- const response_1 = require("./response");
5
- const request_1 = require("./request");
6
- const application_1 = require("./application");
1
+ import { MockResponse } from "./response/index.js";
2
+ import { MockRequest } from "./request/index.js";
3
+ import { MockApplication } from "./application/index.js";
7
4
  /**
8
5
  * Http mock class
9
6
  * */
10
7
  class HttpMock {
8
+ /**
9
+ * Is it initialized?
10
+ * */
11
+ _initialized;
11
12
  /** @inheritDoc */
12
13
  init(req) {
13
14
  if (this._initialized) {
14
15
  return;
15
16
  }
16
17
  this._initialized = true;
17
- request_1.MockRequest.setFirstOrigin(req);
18
- response_1.MockResponse.setFirstOrigin(req.res);
19
- application_1.MockApplication.setFirstOrigin(req.app);
18
+ MockRequest.setFirstOrigin(req);
19
+ MockResponse.setFirstOrigin(req.res);
20
+ MockApplication.setFirstOrigin(req.app);
20
21
  }
21
22
  /** @inheritDoc */
22
23
  fork() {
23
- return [request_1.MockRequest.firstOrigin, response_1.MockResponse.firstOrigin, application_1.MockApplication.firstOrigin];
24
+ return [MockRequest.firstOrigin, MockResponse.firstOrigin, MockApplication.firstOrigin];
24
25
  }
25
26
  /** @inheritDoc */
26
27
  forBulk(req, service, resolver, custom) {
27
- var _a;
28
- const newReq = new request_1.MockRequest(service, req, custom);
29
- const newRes = new response_1.MockResponse(resolver, req.res);
30
- const newApp = (_a = application_1.MockApplication.firstOrigin) !== null && _a !== void 0 ? _a : new application_1.MockApplication(req.app);
28
+ const newReq = new MockRequest(service, req, custom);
29
+ const newRes = new MockResponse(resolver, req.res);
30
+ const newApp = MockApplication.firstOrigin ?? new MockApplication(req.app);
31
31
  return [newReq, newRes, newApp];
32
32
  }
33
33
  }
@@ -37,5 +37,4 @@ class HttpMock {
37
37
  *
38
38
  * @type {HttpMockLike}
39
39
  * */
40
- exports.httpMock = new HttpMock();
41
- //# sourceMappingURL=http-mock.js.map
40
+ export const httpMock = new HttpMock();
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export * from './enum';
2
- export * from './application';
3
- export * from './request';
4
- export * from './response';
5
- export * from './http-mock';
6
- export * from './index.types';
7
- export * from './loader';
1
+ export * from './enum/index.js';
2
+ export * from './application/index.js';
3
+ export * from './request/index.js';
4
+ export * from './response/index.js';
5
+ export * from './http-mock.js';
6
+ export * from './index.types.js';
7
+ export * from './index.loader.js';
8
+ export * from './index.foretell.js';
@@ -0,0 +1 @@
1
+ export declare const foretell_leyyoHttpMock: (() => void)[];
@@ -0,0 +1,19 @@
1
+ // noinspection JSUnusedGlobalSymbols
2
+ import { foretell_leyyoCommon, literalPool } from "@leyyo/common";
3
+ import { FQN } from "./internal.js";
4
+ export const foretell_leyyoHttpMock = [
5
+ // dependencies
6
+ ...foretell_leyyoCommon,
7
+ () => literalPool.register({
8
+ name: 'HttpMethod',
9
+ fqn: FQN,
10
+ i18n: true,
11
+ lazyTarget: import('./enum/http-method.js').then(m => m.HttpMethodItems)
12
+ }),
13
+ () => literalPool.register({
14
+ name: 'HttpProtocol',
15
+ fqn: FQN,
16
+ i18n: true,
17
+ lazyTarget: import('./enum/http-protocol.js').then(m => m.HttpProtocolItems)
18
+ })
19
+ ];
package/dist/index.js CHANGED
@@ -1,24 +1,8 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./enum"), exports);
18
- __exportStar(require("./application"), exports);
19
- __exportStar(require("./request"), exports);
20
- __exportStar(require("./response"), exports);
21
- __exportStar(require("./http-mock"), exports);
22
- __exportStar(require("./index.types"), exports);
23
- __exportStar(require("./loader"), exports);
24
- //# sourceMappingURL=index.js.map
1
+ export * from './enum/index.js';
2
+ export * from './application/index.js';
3
+ export * from './request/index.js';
4
+ export * from './response/index.js';
5
+ export * from './http-mock.js';
6
+ export * from './index.types.js';
7
+ export * from './index.loader.js';
8
+ export * from './index.foretell.js';
@@ -1,2 +1 @@
1
1
  export declare const loader_leyyoHttpMock: import("@leyyo/common").LoaderLike;
2
- export declare const foretell_leyyoHttpMock: (() => void)[];
@@ -0,0 +1,10 @@
1
+ // noinspection JSUnusedGlobalSymbols
2
+ import { defineLoader, loader_leyyoCommon } from "@leyyo/common";
3
+ import { FQN } from "./internal.js";
4
+ export const loader_leyyoHttpMock = defineLoader(FQN,
5
+ // dependencies
6
+ ...loader_leyyoCommon,
7
+ // enums
8
+ () => import('./enum/http-method.js').then(m => m.HttpMethodItems), () => import('./enum/http-protocol.js').then(m => m.HttpProtocolItems),
9
+ // classes
10
+ () => import('./application/mock-application.js').then(m => m.MockApplication), () => import('./request/mock.request.js').then(m => m.MockRequest), () => import('./response/mock-response.js').then(m => m.MockResponse));
@@ -1,6 +1,6 @@
1
1
  import { Application, Request, Response } from "express";
2
- import { MockResponseResolve, ResponseData } from "./response";
3
- import { MockServiceRequest } from "./request";
2
+ import { MockResponseResolve, ResponseData } from "./response/index.js";
3
+ import { MockServiceRequest } from "./request/index.js";
4
4
  import { Dict } from "@leyyo/common";
5
5
  export type HttpMockTuple = [Request, Response, Application];
6
6
  /**
@@ -1,3 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.types.js.map
1
+ export {};
@@ -1 +1 @@
1
- export declare const FQN = "leyyo.http-mock";
1
+ export declare const NME: string, FQN: string, VER: string, CNF: import("@leyyo/common").LeyyoConfig;
package/dist/internal.js CHANGED
@@ -1,6 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FQN = void 0;
4
- // noinspection JSUnusedGlobalSymbols
5
- exports.FQN = 'leyyo.http-mock';
6
- //# sourceMappingURL=internal.js.map
1
+ import { sysAll } from '@leyyo/common';
2
+ export const { pck: { name: NME, fqn: FQN, version: VER }, config: CNF } = sysAll(import.meta.url);
@@ -1,2 +1,2 @@
1
- export * from './index.types';
2
- export * from './mock.request';
1
+ export * from './index.types.js';
2
+ export * from './mock.request.js';
@@ -1,19 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
18
- __exportStar(require("./mock.request"), exports);
19
- //# sourceMappingURL=index.js.map
1
+ export * from './index.types.js';
2
+ export * from './mock.request.js';
@@ -1,8 +1,8 @@
1
1
  import { Request } from "express";
2
- import { ResponseData } from "../response";
2
+ import { ResponseData } from "../response/index.js";
3
3
  import { Arr } from "@leyyo/common";
4
- import { HttpCookies, HttpData, HttpHeaders, HttpParams, HttpQuery } from "../event";
5
- import { HttpMethod } from "../enum";
4
+ import { HttpCookies, HttpData, HttpHeaders, HttpParams, HttpQuery } from "../event/index.js";
5
+ import { HttpMethod } from "../enum/index.js";
6
6
  export interface RequestLocal {
7
7
  }
8
8
  export type RequestBody = Arr | HttpData | string | unknown;
@@ -1,3 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.types.js.map
1
+ export {};
@@ -2,11 +2,11 @@ import { Application, MediaType, NextFunction, Request, Response } from "express
2
2
  import { Socket } from "net";
3
3
  import { IncomingHttpHeaders } from "http";
4
4
  import RangeParser from "range-parser";
5
- import { MockRequestLike, MockServiceRequest, PipeOption, RequestBody, RequestErrorCallback, RequestLocal } from "./index.types";
6
- import { _StreamAbort, _StreamBool, _StreamCompose, _StreamGeneric, _StreamIterator, _StreamReduce, _StreamVoid, HttpCookies, HttpEvent, HttpParams, HttpQuery } from "../event";
5
+ import { MockRequestLike, MockServiceRequest, PipeOption, RequestBody, RequestErrorCallback, RequestLocal } from "./index.types.js";
6
+ import { _StreamAbort, _StreamBool, _StreamCompose, _StreamGeneric, _StreamIterator, _StreamReduce, _StreamVoid, HttpCookies, HttpEvent, HttpParams, HttpQuery } from "../event/index.js";
7
7
  import { Dict, Fnc, HttpStatus, OneOrMore } from "@leyyo/common";
8
8
  import { ArrayOptions, Readable } from "node:stream";
9
- import { HttpMethod, HttpProtocol } from "../enum";
9
+ import { HttpMethod, HttpProtocol } from "../enum/index.js";
10
10
  export declare class MockRequest<B extends RequestBody = RequestBody, L extends RequestLocal = RequestLocal> extends HttpEvent<Request> implements MockRequestLike<B, L> {
11
11
  /** @inheritDoc */
12
12
  readonly isFake: boolean;
@@ -1,11 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MockRequest = void 0;
4
- const event_1 = require("../event");
5
- const common_1 = require("@leyyo/common");
1
+ import { HttpEvent } from "../event/index.js";
2
+ import { delay, logCommon } from "@leyyo/common";
6
3
  let _firstOrigin;
7
4
  // noinspection JSUnusedGlobalSymbols
8
- class MockRequest extends event_1.HttpEvent {
5
+ export class MockRequest extends HttpEvent {
6
+ // region property
7
+ /** @inheritDoc */
8
+ isFake;
9
+ /** @inheritDoc */
10
+ locals;
9
11
  // endregion property
10
12
  // region constructor
11
13
  /**
@@ -22,10 +24,69 @@ class MockRequest extends event_1.HttpEvent {
22
24
  _attachCustom(this, custom);
23
25
  _checkRoute(this);
24
26
  }
27
+ // endregion constructor
28
+ // region express
29
+ /** @inheritDoc*/
30
+ accepted;
31
+ /** @inheritDoc*/
32
+ protocol;
33
+ /** @inheritDoc*/
34
+ secure;
35
+ /** @inheritDoc*/
36
+ ip;
37
+ /** @inheritDoc*/
38
+ ips;
39
+ /** @inheritDoc*/
40
+ subdomains;
41
+ /** @inheritDoc*/
42
+ path;
43
+ /** @inheritDoc*/
44
+ host;
45
+ /** @inheritDoc*/
46
+ hostname;
47
+ /** @inheritDoc*/
48
+ httpVersion;
49
+ /** @inheritDoc*/
50
+ httpVersionMajor;
51
+ /** @inheritDoc*/
52
+ httpVersionMinor;
53
+ /** @inheritDoc*/
54
+ fresh;
55
+ /** @inheritDoc*/
56
+ stale;
57
+ /** @inheritDoc*/
58
+ xhr;
59
+ /** @inheritDoc*/
60
+ body;
61
+ /** @inheritDoc*/
62
+ cookies;
63
+ /** @inheritDoc*/
64
+ method;
65
+ /** @inheritDoc*/
66
+ params;
67
+ /** @inheritDoc*/
68
+ query;
69
+ /** @inheritDoc*/
70
+ route;
71
+ /** @inheritDoc*/
72
+ signedCookies;
73
+ /** @inheritDoc*/
74
+ originalUrl;
75
+ /** @inheritDoc*/
76
+ url;
77
+ /** @inheritDoc*/
78
+ baseUrl;
79
+ /** @inheritDoc*/
80
+ app;
81
+ /** @inheritDoc*/
82
+ res;
83
+ /** @inheritDoc*/
84
+ next;
85
+ /** @inheritDoc*/
86
+ headers;
25
87
  /** @inheritDoc*/
26
88
  is(t) {
27
- var _a, _b;
28
- return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.is(t)) !== null && _b !== void 0 ? _b : false;
89
+ return this._origin?.is(t) ?? false;
29
90
  }
30
91
  /** @inheritDoc*/
31
92
  get(n) {
@@ -37,29 +98,46 @@ class MockRequest extends event_1.HttpEvent {
37
98
  }
38
99
  /** @inheritDoc*/
39
100
  accepts(...t) {
40
- var _a;
41
- return (_a = this._origin) === null || _a === void 0 ? void 0 : _a.accepts(...t);
101
+ return this._origin?.accepts(...t);
42
102
  }
43
103
  /** @inheritDoc*/
44
104
  acceptsCharsets(...c) {
45
- var _a;
46
- return (_a = this._origin) === null || _a === void 0 ? void 0 : _a.acceptsCharsets(...c);
105
+ return this._origin?.acceptsCharsets(...c);
47
106
  }
48
107
  /** @inheritDoc*/
49
108
  acceptsEncodings(...e) {
50
- var _a;
51
- return (_a = this._origin) === null || _a === void 0 ? void 0 : _a.acceptsEncodings(...e);
109
+ return this._origin?.acceptsEncodings(...e);
52
110
  }
53
111
  /** @inheritDoc*/
54
112
  acceptsLanguages(...l) {
55
- var _a;
56
- return (_a = this._origin) === null || _a === void 0 ? void 0 : _a.acceptsLanguages(...l);
113
+ return this._origin?.acceptsLanguages(...l);
57
114
  }
58
115
  /** @inheritDoc*/
59
116
  range(s, o) {
60
- var _a, _b;
61
- return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.range(s, o)) !== null && _b !== void 0 ? _b : -1;
117
+ return this._origin?.range(s, o) ?? -1;
62
118
  }
119
+ // endregion express
120
+ // region http
121
+ /** @inheritDoc*/
122
+ aborted;
123
+ /** @inheritDoc*/
124
+ complete;
125
+ /** @inheritDoc*/
126
+ statusCode;
127
+ /** @inheritDoc*/
128
+ statusMessage;
129
+ /** @inheritDoc*/
130
+ socket;
131
+ /** @inheritDoc*/
132
+ headersDistinct;
133
+ /** @inheritDoc*/
134
+ rawHeaders;
135
+ /** @inheritDoc*/
136
+ trailers;
137
+ /** @inheritDoc*/
138
+ rawTrailers;
139
+ /** @inheritDoc*/
140
+ trailersDistinct;
63
141
  /** @inheritDoc*/
64
142
  get connection() {
65
143
  logger.warn('Should not be called', { fn: 'connection' });
@@ -85,9 +163,33 @@ class MockRequest extends event_1.HttpEvent {
85
163
  /** @inheritDoc*/
86
164
  [Symbol.asyncDispose]() {
87
165
  logger.warn('Should not be called', { fn: 'asyncDispose' });
88
- return this._origin ? this._origin[Symbol.asyncDispose]() : (0, common_1.delay)(100);
166
+ return this._origin ? this._origin[Symbol.asyncDispose]() : delay(100);
89
167
  }
90
168
  /** @inheritDoc*/
169
+ closed;
170
+ /** @inheritDoc*/
171
+ errored;
172
+ /** @inheritDoc*/
173
+ destroyed;
174
+ /** @inheritDoc*/
175
+ readableDidRead;
176
+ /** @inheritDoc*/
177
+ readableEncoding;
178
+ /** @inheritDoc*/
179
+ readableEnded;
180
+ /** @inheritDoc*/
181
+ readableAborted;
182
+ /** @inheritDoc*/
183
+ readableFlowing;
184
+ /** @inheritDoc*/
185
+ readableHighWaterMark;
186
+ /** @inheritDoc*/
187
+ readableLength;
188
+ /** @inheritDoc*/
189
+ readableObjectMode;
190
+ /** @inheritDoc*/
191
+ readable;
192
+ /** @inheritDoc*/
91
193
  _construct(_c) {
92
194
  logger.warn('Should not be called', { fn: '_construct' });
93
195
  }
@@ -166,7 +268,7 @@ class MockRequest extends event_1.HttpEvent {
166
268
  /** @inheritDoc*/
167
269
  every(_f, _o) {
168
270
  logger.warn('Should not be called', { fn: 'every' });
169
- return (0, common_1.delay)(10, false);
271
+ return delay(10, false);
170
272
  }
171
273
  /** @inheritDoc*/
172
274
  filter(_f, _o) {
@@ -176,7 +278,7 @@ class MockRequest extends event_1.HttpEvent {
176
278
  /** @inheritDoc*/
177
279
  find(_f, _o) {
178
280
  logger.warn('Should not be called', { fn: 'find' });
179
- return (0, common_1.delay)(10);
281
+ return delay(10);
180
282
  }
181
283
  /** @inheritDoc*/
182
284
  flatMap(_f, _o) {
@@ -186,7 +288,7 @@ class MockRequest extends event_1.HttpEvent {
186
288
  /** @inheritDoc*/
187
289
  forEach(_f, _o) {
188
290
  logger.warn('Should not be called', { fn: 'forEach' });
189
- return (0, common_1.delay)(10);
291
+ return delay(10);
190
292
  }
191
293
  /** @inheritDoc*/
192
294
  iterator(_o) {
@@ -201,12 +303,12 @@ class MockRequest extends event_1.HttpEvent {
201
303
  /** @inheritDoc*/
202
304
  reduce(_f, _i, _o) {
203
305
  logger.warn('Should not be called', { fn: 'reduce' });
204
- return (0, common_1.delay)(10);
306
+ return delay(10);
205
307
  }
206
308
  /** @inheritDoc*/
207
309
  some(_f, _o) {
208
310
  logger.warn('Should not be called', { fn: 'some' });
209
- return (0, common_1.delay)(10, false);
311
+ return delay(10, false);
210
312
  }
211
313
  /** @inheritDoc*/
212
314
  take(_l, _o) {
@@ -216,14 +318,13 @@ class MockRequest extends event_1.HttpEvent {
216
318
  /** @inheritDoc*/
217
319
  toArray(_o) {
218
320
  logger.warn('Should not be called', { fn: 'toArray' });
219
- return (0, common_1.delay)(10, []);
321
+ return delay(10, []);
220
322
  }
221
323
  // endregion stream
222
324
  // region method
223
325
  /** @inheritDoc*/
224
326
  param(name, defaultValue) {
225
- var _a;
226
- return (_a = this.params[name]) !== null && _a !== void 0 ? _a : defaultValue;
327
+ return this.params[name] ?? defaultValue;
227
328
  }
228
329
  // endregion method
229
330
  // region static
@@ -257,8 +358,7 @@ class MockRequest extends event_1.HttpEvent {
257
358
  return _firstOrigin;
258
359
  }
259
360
  }
260
- exports.MockRequest = MockRequest;
261
- const logger = (0, common_1.newLogger)(MockRequest);
361
+ const logger = logCommon.of(MockRequest);
262
362
  // region functions
263
363
  function _removePath(req) {
264
364
  try {
@@ -275,7 +375,6 @@ function _removePath(req) {
275
375
  * @param {MockServiceRequest} service - service request object
276
376
  * */
277
377
  function _attachService(req, service) {
278
- var _a, _b, _g, _h, _j;
279
378
  if (!service) {
280
379
  service = {
281
380
  method: 'get',
@@ -287,12 +386,12 @@ function _attachService(req, service) {
287
386
  };
288
387
  }
289
388
  req['isFake'] = true;
290
- req.method = (_a = service.method) !== null && _a !== void 0 ? _a : 'get';
291
- req.url = (_b = service.url) !== null && _b !== void 0 ? _b : '';
389
+ req.method = service.method ?? 'get';
390
+ req.url = service.url ?? '';
292
391
  req.body = service.body;
293
- req.headers = (_g = service.headers) !== null && _g !== void 0 ? _g : {};
294
- req.cookies = (_h = service === null || service === void 0 ? void 0 : service.cookies) !== null && _h !== void 0 ? _h : {};
295
- req.signedCookies = (_j = service === null || service === void 0 ? void 0 : service.signedCookies) !== null && _j !== void 0 ? _j : {};
392
+ req.headers = service.headers ?? {};
393
+ req.cookies = service?.cookies ?? {};
394
+ req.signedCookies = service?.signedCookies ?? {};
296
395
  }
297
396
  /**
298
397
  * Attach first real request
@@ -301,7 +400,7 @@ function _attachService(req, service) {
301
400
  * @param {Request} origin
302
401
  * */
303
402
  function _attachOrigin(_req, origin) {
304
- origin = origin !== null && origin !== void 0 ? origin : _firstOrigin;
403
+ origin = origin ?? _firstOrigin;
305
404
  if (origin) {
306
405
  // Clear specific values
307
406
  origin.body = undefined;
@@ -339,4 +438,3 @@ function _checkRoute(req) {
339
438
  }
340
439
  }
341
440
  // endregion functions
342
- //# sourceMappingURL=mock.request.js.map
@@ -1,6 +1,6 @@
1
1
  import { CookieOptions, Response } from "express";
2
2
  import { Arr, Dict, HttpStatus } from "@leyyo/common";
3
- import { HttpData, HttpHeaders } from "../event";
3
+ import { HttpData, HttpHeaders } from "../event/index.js";
4
4
  /**
5
5
  * Response local storage
6
6
  * */
@@ -1,3 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index-types.js.map
1
+ export {};
@@ -1,2 +1,2 @@
1
- export * from './index-types';
2
- export * from './mock-response';
1
+ export * from './index-types.js';
2
+ export * from './mock-response.js';
@@ -1,19 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index-types"), exports);
18
- __exportStar(require("./mock-response"), exports);
19
- //# sourceMappingURL=index.js.map
1
+ export * from './index-types.js';
2
+ export * from './mock-response.js';
@@ -1,8 +1,8 @@
1
1
  import { Application, CookieOptions, Errback, Request, Response } from "express";
2
2
  import { Socket } from "net";
3
- import { MockResponseLike, MockResponseResolve, ResponseData, ResponseErrorCallback, ResponseLocal } from "./index-types";
3
+ import { MockResponseLike, MockResponseResolve, ResponseData, ResponseErrorCallback, ResponseLocal } from "./index-types.js";
4
4
  import { Dict, HttpStatus, KeyValue, OneOrMore } from "@leyyo/common";
5
- import { HttpEvent } from "../event";
5
+ import { HttpEvent } from "../event/index.js";
6
6
  import { OutgoingHttpHeader, OutgoingHttpHeaders } from "node:http";
7
7
  export declare class MockResponse<R extends ResponseData, L extends ResponseLocal = ResponseLocal> extends HttpEvent<Response> implements MockResponseLike<R, L> {
8
8
  /**