@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.
- package/README.md +3 -394
- package/dist/application/index.d.ts +1 -1
- package/dist/application/index.js +1 -18
- package/dist/application/index.types.js +1 -3
- package/dist/application/mock-application.d.ts +2 -2
- package/dist/application/mock-application.js +25 -13
- package/dist/enum/http-method.js +1 -5
- package/dist/enum/http-protocol.js +1 -5
- package/dist/enum/index.d.ts +2 -2
- package/dist/enum/index.js +2 -19
- package/dist/event/http-event.js +17 -36
- package/dist/event/index.d.ts +2 -2
- package/dist/event/index.js +2 -19
- package/dist/event/index.types.js +1 -3
- package/dist/http-mock.d.ts +1 -1
- package/dist/http-mock.js +15 -16
- package/dist/index.d.ts +8 -7
- package/dist/index.foretell.d.ts +1 -0
- package/dist/index.foretell.js +19 -0
- package/dist/index.js +8 -24
- package/dist/{loader.d.ts → index.loader.d.ts} +0 -1
- package/dist/index.loader.js +10 -0
- package/dist/index.types.d.ts +2 -2
- package/dist/index.types.js +1 -3
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +2 -6
- package/dist/request/index.d.ts +2 -2
- package/dist/request/index.js +2 -19
- package/dist/request/index.types.d.ts +3 -3
- package/dist/request/index.types.js +1 -3
- package/dist/request/mock.request.d.ts +3 -3
- package/dist/request/mock.request.js +135 -37
- package/dist/response/index-types.d.ts +1 -1
- package/dist/response/index-types.js +1 -3
- package/dist/response/index.d.ts +2 -2
- package/dist/response/index.js +2 -19
- package/dist/response/mock-response.d.ts +2 -2
- package/dist/response/mock-response.js +98 -46
- package/package.json +6 -5
- package/dist/application/index.js.map +0 -1
- package/dist/application/index.types.js.map +0 -1
- package/dist/application/mock-application.js.map +0 -1
- package/dist/enum/http-method.js.map +0 -1
- package/dist/enum/http-protocol.js.map +0 -1
- package/dist/enum/index.js.map +0 -1
- package/dist/event/http-event.js.map +0 -1
- package/dist/event/index.js.map +0 -1
- package/dist/event/index.types.js.map +0 -1
- package/dist/http-mock.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.types.js.map +0 -1
- package/dist/internal.js.map +0 -1
- package/dist/loader.js +0 -64
- package/dist/loader.js.map +0 -1
- package/dist/request/index.js.map +0 -1
- package/dist/request/index.types.js.map +0 -1
- package/dist/request/mock.request.js.map +0 -1
- package/dist/response/index-types.js.map +0 -1
- package/dist/response/index.js.map +0 -1
- package/dist/response/mock-response.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,400 +1,9 @@
|
|
|
1
|
-
# Leyyo:
|
|
2
|
-
|
|
1
|
+
# Leyyo: Http Mock
|
|
2
|
+
Http Mock library for Leyyo framework
|
|
3
3
|
|
|
4
4
|
## Import
|
|
5
|
-
- `npm i @leyyo/
|
|
5
|
+
- `npm i @leyyo/http-mock`
|
|
6
6
|
|
|
7
|
-
## Usage (Runtime)
|
|
8
|
-
|
|
9
|
-
### Country Code
|
|
10
|
-
> All country codes with alpha 3 and related language codes
|
|
11
|
-
>
|
|
12
|
-
> @see [ISO 3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
|
|
13
|
-
>
|
|
14
|
-
```typescript
|
|
15
|
-
import {countryHandler} from "@leyyo/localization";
|
|
16
|
-
|
|
17
|
-
/*
|
|
18
|
-
* Country exists
|
|
19
|
-
*/
|
|
20
|
-
console.log(countryHandler.has('IE'));
|
|
21
|
-
// ==> true
|
|
22
|
-
|
|
23
|
-
/*
|
|
24
|
-
* Get country object as
|
|
25
|
-
* {code: string, name: string, alpha: string, languages: string[]}
|
|
26
|
-
*/
|
|
27
|
-
console.log(countryHandler.get('IE'));
|
|
28
|
-
// ==> {code: 'IE', name: 'Ireland', alpha3: 'IRL', languages: ['en', 'ga']}
|
|
29
|
-
|
|
30
|
-
/*
|
|
31
|
-
* Get name of country
|
|
32
|
-
*/
|
|
33
|
-
console.log(countryHandler.getName('IE'));
|
|
34
|
-
// ==> 'Ireland'
|
|
35
|
-
|
|
36
|
-
/*
|
|
37
|
-
* Get alpha 3 code of country
|
|
38
|
-
*/
|
|
39
|
-
console.log(countryHandler.getAlpha3('IE'));
|
|
40
|
-
// ==> 'IRL'
|
|
41
|
-
|
|
42
|
-
/*
|
|
43
|
-
* Get used languages of country
|
|
44
|
-
*/
|
|
45
|
-
console.log(countryHandler.getLanguages('IE'));
|
|
46
|
-
// ==> ['en', 'ga']
|
|
47
|
-
|
|
48
|
-
/*
|
|
49
|
-
* Find all countries by given used language codes
|
|
50
|
-
*/
|
|
51
|
-
console.log(countryHandler.findByLanguage('ga'));
|
|
52
|
-
// ==> ['IE', ...]
|
|
53
|
-
|
|
54
|
-
/*
|
|
55
|
-
* Get country objects by given country codes
|
|
56
|
-
*/
|
|
57
|
-
console.log(countryHandler.getSelected('IE', 'KE'));
|
|
58
|
-
// ==> [
|
|
59
|
-
// {code: 'IE', name: 'Ireland', alpha3: 'IRL', languages: ['en', 'ga']},
|
|
60
|
-
// {code: 'KE', name: 'Kenya', alpha3: 'KEN', languages: ['sw', 'en']}
|
|
61
|
-
// ]
|
|
62
|
-
|
|
63
|
-
/*
|
|
64
|
-
* List all country objects
|
|
65
|
-
*
|
|
66
|
-
* @note it can be used during combo
|
|
67
|
-
*/
|
|
68
|
-
console.log(countryHandler.getAll()); // A-Z ordered
|
|
69
|
-
// ==> [{code: 'AD', name: 'Andorra', alpha3: 'AND', languages: ['ca']}, ...]
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
* List all country codes
|
|
73
|
-
*
|
|
74
|
-
* @note it can be used during validations
|
|
75
|
-
*/
|
|
76
|
-
console.log(countryHandler.codes); // A-Z ordered
|
|
77
|
-
// ==> ['AD', 'AE', 'AF', 'AG', 'AI', 'AL', ...]
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Exchange Code
|
|
82
|
-
> All exchange codes with symbol, number and related country codes
|
|
83
|
-
>
|
|
84
|
-
> @see [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)
|
|
85
|
-
>
|
|
86
|
-
```typescript
|
|
87
|
-
import {exchangeHandler} from "@leyyo/localization-common";
|
|
88
|
-
|
|
89
|
-
/*
|
|
90
|
-
* Exchange exists
|
|
91
|
-
*/
|
|
92
|
-
console.log(exchangeHandler.has('USD'));
|
|
93
|
-
// ==> true
|
|
94
|
-
|
|
95
|
-
/*
|
|
96
|
-
* Get exchange object as
|
|
97
|
-
* {code: string, name: string, symbol: string, number: number, countries: string[]}
|
|
98
|
-
*/
|
|
99
|
-
console.log(exchangeHandler.get('USD'));
|
|
100
|
-
// ==> {code: 'USD', name: 'US Dollar', symbol: '$', number: 840, countries: ['AS', 'GU', 'IO', 'US', 'VG', ...]}
|
|
101
|
-
|
|
102
|
-
/*
|
|
103
|
-
* Get name of exchange
|
|
104
|
-
*/
|
|
105
|
-
console.log(exchangeHandler.getName('USD'));
|
|
106
|
-
// ==> 'US Dollar'
|
|
107
|
-
|
|
108
|
-
/*
|
|
109
|
-
* Get symbol of exchange
|
|
110
|
-
*/
|
|
111
|
-
console.log(exchangeHandler.getSymbol('USD'));
|
|
112
|
-
// ==> '$'
|
|
113
|
-
|
|
114
|
-
/*
|
|
115
|
-
* Get number of exchange
|
|
116
|
-
*/
|
|
117
|
-
console.log(exchangeHandler.getNumber('USD'));
|
|
118
|
-
// ==> 840
|
|
119
|
-
|
|
120
|
-
/*
|
|
121
|
-
* Get related countries of exchange
|
|
122
|
-
*/
|
|
123
|
-
console.log(exchangeHandler.getCountries('USD'));
|
|
124
|
-
// ==> ['AS', 'GU', 'IO', 'US', 'VG', ...]
|
|
125
|
-
|
|
126
|
-
/*
|
|
127
|
-
* Find all exchanges by given country code
|
|
128
|
-
*/
|
|
129
|
-
console.log(exchangeHandler.findByCountry('US'));
|
|
130
|
-
// ==> ['USD', ...]
|
|
131
|
-
|
|
132
|
-
/*
|
|
133
|
-
* Get exchange objects by given codes
|
|
134
|
-
*/
|
|
135
|
-
console.log(exchangeHandler.getSelected('USD', 'EUR'));
|
|
136
|
-
// ==> [
|
|
137
|
-
// {code: 'USD', name: 'US Dollar', symbol: '$', number: 840, countries: ['AS', 'GU', 'IO', 'US', 'VG', ...]},
|
|
138
|
-
// {code: 'EUR', name: 'Euro', symbol: '€', number: 978, countries: ["GB", "AD", "AT", "BE", "CY", ...]}
|
|
139
|
-
// ]
|
|
140
|
-
|
|
141
|
-
/*
|
|
142
|
-
* List all exchange objects
|
|
143
|
-
*
|
|
144
|
-
* @note it can be used during combo
|
|
145
|
-
*/
|
|
146
|
-
console.log(exchangeHandler.getAll()); // A-Z ordered
|
|
147
|
-
// ==> [{code: 'AED', name: 'UAE Dirham', symbol: 'د.إ', number: 784, countries: ['AE']}, ...]
|
|
148
|
-
|
|
149
|
-
/*
|
|
150
|
-
* List all country codes
|
|
151
|
-
*
|
|
152
|
-
* @note it can be used during validations
|
|
153
|
-
*/
|
|
154
|
-
console.log(exchangeHandler.codes); // A-Z ordered
|
|
155
|
-
// ==> ['AED', 'AFN', 'ALL', 'AMD', 'AOA', 'ARS', 'AWG', ...]
|
|
156
|
-
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### Language Code
|
|
160
|
-
> All language codes
|
|
161
|
-
>
|
|
162
|
-
> @see [ISO 639](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)
|
|
163
|
-
>
|
|
164
|
-
```typescript
|
|
165
|
-
import {languageHandler} from "@leyyo/localization-common";
|
|
166
|
-
|
|
167
|
-
/*
|
|
168
|
-
* Language exists
|
|
169
|
-
*/
|
|
170
|
-
console.log(languageHandler.has('tr'));
|
|
171
|
-
// ==> true
|
|
172
|
-
|
|
173
|
-
/*
|
|
174
|
-
* Get language object as {code: string, name: string}
|
|
175
|
-
*/
|
|
176
|
-
console.log(languageHandler.get('tr'));
|
|
177
|
-
// ==> {code: 'tr', name: 'Turkish'}
|
|
178
|
-
|
|
179
|
-
/*
|
|
180
|
-
* Get name of language
|
|
181
|
-
*/
|
|
182
|
-
console.log(languageHandler.getName('tr'));
|
|
183
|
-
// ==> 'Turkish'
|
|
184
|
-
|
|
185
|
-
/*
|
|
186
|
-
* Get language objects by given codes
|
|
187
|
-
*/
|
|
188
|
-
console.log(languageHandler.getSelected('tr', 'bg'));
|
|
189
|
-
// ==> [
|
|
190
|
-
// {code: 'tr', name: 'Turkish'},
|
|
191
|
-
// {code: 'bg', name: 'Bulgarian'}
|
|
192
|
-
// ]
|
|
193
|
-
|
|
194
|
-
/*
|
|
195
|
-
* List all language objects
|
|
196
|
-
*
|
|
197
|
-
* @note it can be used during combo
|
|
198
|
-
*/
|
|
199
|
-
console.log(languageHandler.getAll()); // A-Z ordered
|
|
200
|
-
// ==> [{code: 'aa', name: 'Afar'}, ...]
|
|
201
|
-
|
|
202
|
-
/*
|
|
203
|
-
* List all language codes
|
|
204
|
-
*
|
|
205
|
-
* @note it can be used during validations
|
|
206
|
-
*/
|
|
207
|
-
console.log(languageHandler.codes); // A-Z ordered
|
|
208
|
-
// ==> ['aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'ar', 'as', 'av', 'ay', 'az', ...]
|
|
209
|
-
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### Locale Code
|
|
213
|
-
> All locale codes
|
|
214
|
-
>
|
|
215
|
-
> @see [IANA](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry)
|
|
216
|
-
>
|
|
217
|
-
> **Note**
|
|
218
|
-
> It also covers language codes
|
|
219
|
-
>
|
|
220
|
-
```typescript
|
|
221
|
-
import {localeHandler} from "@leyyo/localization-common";
|
|
222
|
-
|
|
223
|
-
/*
|
|
224
|
-
* Locale exists
|
|
225
|
-
*/
|
|
226
|
-
console.log(localeHandler.has('es-ve'));
|
|
227
|
-
// ==> true
|
|
228
|
-
|
|
229
|
-
/*
|
|
230
|
-
* Get locale object as
|
|
231
|
-
* {code: string, name: string, language?: string, countries: string[]}
|
|
232
|
-
*/
|
|
233
|
-
console.log(localeHandler.get('es-ve'));
|
|
234
|
-
// ==> {code: 'es-ve', name: 'Spanish (Venezuela)', language: 'es', countries: ['VE']}
|
|
235
|
-
|
|
236
|
-
/*
|
|
237
|
-
* Get name of locale
|
|
238
|
-
*/
|
|
239
|
-
console.log(localeHandler.getName('es-ve'));
|
|
240
|
-
// ==> 'Spanish (Venezuela)'
|
|
241
|
-
|
|
242
|
-
/*
|
|
243
|
-
* Get language of locale
|
|
244
|
-
*/
|
|
245
|
-
console.log(localeHandler.getLanguage('es-ve'));
|
|
246
|
-
// ==> 'es'
|
|
247
|
-
|
|
248
|
-
/*
|
|
249
|
-
* Get countries of locale
|
|
250
|
-
*/
|
|
251
|
-
console.log(localeHandler.getCountries('es-ve'));
|
|
252
|
-
// ==> ['VE']
|
|
253
|
-
|
|
254
|
-
/*
|
|
255
|
-
* Get locale objects by given codes
|
|
256
|
-
*/
|
|
257
|
-
console.log(localeHandler.getSelected('es-ve', 'fr-mc'));
|
|
258
|
-
// ==> [
|
|
259
|
-
// {code: 'es-ve', name: 'Spanish (Venezuela)', language: 'es', countries: ['VE']},
|
|
260
|
-
// {code: 'fr-mc', name: 'French (Monaco)', language: 'fr', countries: ['MC']}
|
|
261
|
-
// ]
|
|
262
|
-
|
|
263
|
-
/*
|
|
264
|
-
* List all locale objects
|
|
265
|
-
*
|
|
266
|
-
* @note it can be used during combo
|
|
267
|
-
*/
|
|
268
|
-
console.log(localeHandler.getAll()); // A-Z ordered
|
|
269
|
-
// ==> [{code: 'af', name: 'Afrikaans', language: 'af', countries: ['ZA']}, ...]
|
|
270
|
-
|
|
271
|
-
/*
|
|
272
|
-
* List all locale codes
|
|
273
|
-
*
|
|
274
|
-
* @note it can be used during validations
|
|
275
|
-
*/
|
|
276
|
-
console.log(localeHandler.codes); // A-Z ordered
|
|
277
|
-
// ==> ['af', 'sq', 'an', 'ar', 'ar-dz', 'ar-bh', 'ar-eg', ...]
|
|
278
|
-
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### Timezone Code
|
|
282
|
-
> All timezone codes
|
|
283
|
-
>
|
|
284
|
-
> @see [TZ](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
|
|
285
|
-
>
|
|
286
|
-
> **Note**
|
|
287
|
-
> It also covers alias timezones
|
|
288
|
-
>
|
|
289
|
-
```typescript
|
|
290
|
-
import {timezoneHandler} from "@leyyo/localization-common";
|
|
291
|
-
|
|
292
|
-
/*
|
|
293
|
-
* Timezone exists
|
|
294
|
-
*/
|
|
295
|
-
console.log(timezoneHandler.has('Africa/Dakar'));
|
|
296
|
-
// ==> true
|
|
297
|
-
|
|
298
|
-
/*
|
|
299
|
-
* Get timezone object as
|
|
300
|
-
* {code: string, name: string, sdt: number, dst: number, parent?: string, countries: string[]}
|
|
301
|
-
*/
|
|
302
|
-
console.log(timezoneHandler.get('Europe/Berlin'));
|
|
303
|
-
// ==> {code: 'Europe/Berlin', name: 'Europe > Berlin', sdt: 1, dst: 2, parent: undefined, countries: ['DE']}
|
|
304
|
-
|
|
305
|
-
/*
|
|
306
|
-
* Get timezone object for alias
|
|
307
|
-
*/
|
|
308
|
-
console.log(timezoneHandler.get('Africa/Dakar')); // it's alias, so points to "Africa/Abidjan"
|
|
309
|
-
// ==> {code: 'Africa/Dakar', name: 'Africa > Abidjan', sdt: 1, dst: 2, parent: 'Africa/Abidjan', countries: ['CI', 'BF', 'GH', 'GM', 'GN', 'IS',...]}
|
|
310
|
-
|
|
311
|
-
/*
|
|
312
|
-
* Get name of timezone
|
|
313
|
-
*/
|
|
314
|
-
console.log(timezoneHandler.getName('Europe/Berlin'));
|
|
315
|
-
// ==> 'Europe > Berlin'
|
|
316
|
-
|
|
317
|
-
/*
|
|
318
|
-
* Get hour for timezone as SDT (3 options)
|
|
319
|
-
*/
|
|
320
|
-
console.log(timezoneHandler.getHour('Europe/Berlin'));
|
|
321
|
-
// ==> 1
|
|
322
|
-
|
|
323
|
-
console.log(timezoneHandler.getSdt('Europe/Berlin'));
|
|
324
|
-
// ==> 1
|
|
325
|
-
|
|
326
|
-
console.log(timezoneHandler.getStandard('Europe/Berlin'));
|
|
327
|
-
// ==> 1
|
|
328
|
-
|
|
329
|
-
/*
|
|
330
|
-
* Get hour for timezone as DST (3 options)
|
|
331
|
-
*/
|
|
332
|
-
console.log(timezoneHandler.getHour('Europe/Berlin', true));
|
|
333
|
-
// ==> 2
|
|
334
|
-
|
|
335
|
-
console.log(timezoneHandler.getDst('Europe/Berlin'));
|
|
336
|
-
// ==> 2
|
|
337
|
-
|
|
338
|
-
console.log(timezoneHandler.getDaylightSaving('Europe/Berlin'));
|
|
339
|
-
// ==> 2
|
|
340
|
-
|
|
341
|
-
/*
|
|
342
|
-
* Get countries of timezone
|
|
343
|
-
*/
|
|
344
|
-
console.log(timezoneHandler.getCountries('Europe/Berlin'));
|
|
345
|
-
// ==> ['DE']
|
|
346
|
-
|
|
347
|
-
/*
|
|
348
|
-
* Get alias status of timezone
|
|
349
|
-
*/
|
|
350
|
-
console.log(timezoneHandler.isAlias('Africa/Dakar'));
|
|
351
|
-
// ==> true
|
|
352
|
-
|
|
353
|
-
console.log(timezoneHandler.isAlias('Africa/Abidjan'));
|
|
354
|
-
// ==> false
|
|
355
|
-
|
|
356
|
-
/*
|
|
357
|
-
* Get timezone objects by given codes
|
|
358
|
-
*/
|
|
359
|
-
console.log(timezoneHandler.getSelected('Europe/Berlin', 'Africa/Dakar'));
|
|
360
|
-
// ==> [
|
|
361
|
-
// {code: 'Europe/Berlin', name: 'Europe > Berlin', sdt: 1, dst: 2, parent: undefined, countries: ['DE']},
|
|
362
|
-
// {code: 'Africa/Dakar', name: 'Africa > Abidjan', sdt: 1, dst: 2, parent: 'Africa/Abidjan', countries: ['CI', 'BF', 'GH', 'GM', 'GN', 'IS',...]}
|
|
363
|
-
// ]
|
|
364
|
-
|
|
365
|
-
/*
|
|
366
|
-
* List all timezone objects
|
|
367
|
-
*
|
|
368
|
-
* @note it can be used during combo
|
|
369
|
-
*/
|
|
370
|
-
console.log(timezoneHandler.getAll()); // A-Z ordered
|
|
371
|
-
// ==> [{code: 'Etc/GMT+1', name: 'Etc > GMT +1', sdt: -1, dst: -1, parent: undefined, countries: []}, ...]
|
|
372
|
-
|
|
373
|
-
/*
|
|
374
|
-
* List all timezone codes
|
|
375
|
-
*
|
|
376
|
-
* @note it can be used during validations
|
|
377
|
-
*/
|
|
378
|
-
console.log(timezoneHandler.codes); // A-Z ordered
|
|
379
|
-
// ==> ['Etc/GMT+1', 'Etc/GMT+2', ...]
|
|
380
|
-
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
## Usage (Design time)
|
|
384
|
-
```typescript
|
|
385
|
-
import type {CountryCode, ExchangeCode, LanguageCode, LocaleCode, TimezoneCode} from "@leyyo/localization-common";
|
|
386
|
-
// please "type" keyword to prevent runtime loading
|
|
387
|
-
|
|
388
|
-
interface MyInterface {
|
|
389
|
-
country: CountryCode;
|
|
390
|
-
exchange: ExchangeCode;
|
|
391
|
-
language: LanguageCode;
|
|
392
|
-
locale: LocaleCode;
|
|
393
|
-
timezone: TimezoneCode;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
```
|
|
398
7
|
|
|
399
8
|
## Standards
|
|
400
9
|
- Language: `TS`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './mock-application';
|
|
1
|
+
export * from './mock-application.js';
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
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("./mock-application"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from './mock-application.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Application, RequestParamHandler, Router } from "express";
|
|
2
2
|
import * as http from "http";
|
|
3
|
-
import { MockApplicationLike } from "./index.types";
|
|
4
|
-
import { HttpEvent } from "../event";
|
|
3
|
+
import { MockApplicationLike } from "./index.types.js";
|
|
4
|
+
import { HttpEvent } from "../event/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Http mock application, it extends express application
|
|
7
7
|
* */
|
|
@@ -1,17 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MockApplication = void 0;
|
|
4
|
-
const event_1 = require("../event");
|
|
5
|
-
const common_1 = require("@leyyo/common");
|
|
1
|
+
import { HttpEvent } from "../event/index.js";
|
|
2
|
+
import { logCommon } from "@leyyo/common";
|
|
6
3
|
let _firstOrigin;
|
|
7
4
|
// noinspection JSUnusedGlobalSymbols
|
|
8
5
|
/**
|
|
9
6
|
* Http mock application, it extends express application
|
|
10
7
|
* */
|
|
11
|
-
class MockApplication extends
|
|
8
|
+
export class MockApplication extends HttpEvent {
|
|
9
|
+
// region properties
|
|
10
|
+
/** @inheritDoc */
|
|
11
|
+
_router;
|
|
12
|
+
/** @inheritDoc */
|
|
13
|
+
locals;
|
|
14
|
+
/** @inheritDoc */
|
|
15
|
+
map;
|
|
16
|
+
/** @inheritDoc */
|
|
17
|
+
mountpath;
|
|
12
18
|
constructor(origin) {
|
|
13
19
|
super(origin);
|
|
14
20
|
}
|
|
21
|
+
/** @inheritDoc */
|
|
22
|
+
resource;
|
|
23
|
+
/** @inheritDoc */
|
|
24
|
+
router;
|
|
25
|
+
/** @inheritDoc */
|
|
26
|
+
routes;
|
|
27
|
+
/** @inheritDoc */
|
|
28
|
+
settings;
|
|
29
|
+
/** @inheritDoc */
|
|
30
|
+
stack;
|
|
15
31
|
// endregion properties
|
|
16
32
|
// region http-methods
|
|
17
33
|
/** @inheritDoc */
|
|
@@ -206,13 +222,11 @@ class MockApplication extends event_1.HttpEvent {
|
|
|
206
222
|
}
|
|
207
223
|
/** @inheritDoc */
|
|
208
224
|
param(name, handler) {
|
|
209
|
-
|
|
210
|
-
return (_d = this._origin) === null || _d === void 0 ? void 0 : _d.param(name, handler);
|
|
225
|
+
return this._origin?.param(name, handler);
|
|
211
226
|
}
|
|
212
227
|
/** @inheritDoc */
|
|
213
228
|
path() {
|
|
214
|
-
|
|
215
|
-
return (_d = this._origin) === null || _d === void 0 ? void 0 : _d.path();
|
|
229
|
+
return this._origin?.path();
|
|
216
230
|
}
|
|
217
231
|
/** @inheritDoc */
|
|
218
232
|
render(_n, _o, _c) {
|
|
@@ -249,6 +263,4 @@ class MockApplication extends event_1.HttpEvent {
|
|
|
249
263
|
return _firstOrigin;
|
|
250
264
|
}
|
|
251
265
|
}
|
|
252
|
-
|
|
253
|
-
const logger = (0, common_1.newLogger)(MockApplication);
|
|
254
|
-
//# sourceMappingURL=mock-application.js.map
|
|
266
|
+
const logger = logCommon.of(MockApplication);
|
package/dist/enum/http-method.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpMethodItems = void 0;
|
|
4
1
|
const literals = [
|
|
5
2
|
'delete',
|
|
6
3
|
'get',
|
|
@@ -17,5 +14,4 @@ const literals = [
|
|
|
17
14
|
/**
|
|
18
15
|
* @type {ReadonlyArray<HttpMethod>}
|
|
19
16
|
* */
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=http-method.js.map
|
|
17
|
+
export const HttpMethodItems = literals;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpProtocolItems = void 0;
|
|
4
1
|
const literals = [
|
|
5
2
|
'http',
|
|
6
3
|
'https',
|
|
@@ -9,5 +6,4 @@ const literals = [
|
|
|
9
6
|
/**
|
|
10
7
|
* @type {ReadonlyArray<HttpProtocol>}
|
|
11
8
|
* */
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=http-protocol.js.map
|
|
9
|
+
export const HttpProtocolItems = literals;
|
package/dist/enum/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './http-method';
|
|
2
|
-
export * from './http-protocol';
|
|
1
|
+
export * from './http-method.js';
|
|
2
|
+
export * from './http-protocol.js';
|
package/dist/enum/index.js
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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("./http-method"), exports);
|
|
18
|
-
__exportStar(require("./http-protocol"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from './http-method.js';
|
|
2
|
+
export * from './http-protocol.js';
|
package/dist/event/http-event.js
CHANGED
|
@@ -1,97 +1,78 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpEvent = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Abstract class for Request and Response
|
|
6
3
|
* */
|
|
7
|
-
class HttpEvent {
|
|
4
|
+
export class HttpEvent {
|
|
5
|
+
_origin;
|
|
8
6
|
constructor(_origin) {
|
|
9
7
|
this._origin = _origin;
|
|
10
8
|
}
|
|
11
9
|
/** @inheritDoc */
|
|
12
10
|
addListener(e, l) {
|
|
13
|
-
|
|
14
|
-
(_a = this._origin) === null || _a === void 0 ? void 0 : _a.addListener(e, l);
|
|
11
|
+
this._origin?.addListener(e, l);
|
|
15
12
|
return this;
|
|
16
13
|
}
|
|
17
14
|
/** @inheritDoc */
|
|
18
15
|
emit(e, ...a) {
|
|
19
|
-
|
|
20
|
-
return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.emit(e, a)) !== null && _b !== void 0 ? _b : false;
|
|
16
|
+
return this._origin?.emit(e, a) ?? false;
|
|
21
17
|
}
|
|
22
18
|
/** @inheritDoc */
|
|
23
19
|
eventNames() {
|
|
24
|
-
|
|
25
|
-
return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.eventNames()) !== null && _b !== void 0 ? _b : [];
|
|
20
|
+
return this._origin?.eventNames() ?? [];
|
|
26
21
|
}
|
|
27
22
|
/** @inheritDoc */
|
|
28
23
|
getMaxListeners() {
|
|
29
|
-
|
|
30
|
-
return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.getMaxListeners()) !== null && _b !== void 0 ? _b : 10;
|
|
24
|
+
return this._origin?.getMaxListeners() ?? 10;
|
|
31
25
|
}
|
|
32
26
|
/** @inheritDoc */
|
|
33
27
|
listenerCount(e) {
|
|
34
|
-
|
|
35
|
-
return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.listenerCount(e)) !== null && _b !== void 0 ? _b : 0;
|
|
28
|
+
return this._origin?.listenerCount(e) ?? 0;
|
|
36
29
|
}
|
|
37
30
|
/** @inheritDoc */
|
|
38
31
|
listeners(e) {
|
|
39
|
-
|
|
40
|
-
return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.listeners(e)) !== null && _b !== void 0 ? _b : [];
|
|
32
|
+
return this._origin?.listeners(e) ?? [];
|
|
41
33
|
}
|
|
42
34
|
/** @inheritDoc */
|
|
43
35
|
off(e, l) {
|
|
44
|
-
|
|
45
|
-
(_a = this._origin) === null || _a === void 0 ? void 0 : _a.off(e, l);
|
|
36
|
+
this._origin?.off(e, l);
|
|
46
37
|
return this;
|
|
47
38
|
}
|
|
48
39
|
/** @inheritDoc */
|
|
49
40
|
on(e, l) {
|
|
50
|
-
|
|
51
|
-
(_a = this._origin) === null || _a === void 0 ? void 0 : _a.on(e, l);
|
|
41
|
+
this._origin?.on(e, l);
|
|
52
42
|
return this;
|
|
53
43
|
}
|
|
54
44
|
/** @inheritDoc */
|
|
55
45
|
once(e, l) {
|
|
56
|
-
|
|
57
|
-
(_a = this._origin) === null || _a === void 0 ? void 0 : _a.once(e, l);
|
|
46
|
+
this._origin?.once(e, l);
|
|
58
47
|
return this;
|
|
59
48
|
}
|
|
60
49
|
/** @inheritDoc */
|
|
61
50
|
prependListener(e, l) {
|
|
62
|
-
|
|
63
|
-
(_a = this._origin) === null || _a === void 0 ? void 0 : _a.prependListener(e, l);
|
|
51
|
+
this._origin?.prependListener(e, l);
|
|
64
52
|
return this;
|
|
65
53
|
}
|
|
66
54
|
/** @inheritDoc */
|
|
67
55
|
prependOnceListener(e, l) {
|
|
68
|
-
|
|
69
|
-
(_a = this._origin) === null || _a === void 0 ? void 0 : _a.prependOnceListener(e, l);
|
|
56
|
+
this._origin?.prependOnceListener(e, l);
|
|
70
57
|
return this;
|
|
71
58
|
}
|
|
72
59
|
/** @inheritDoc */
|
|
73
60
|
rawListeners(e) {
|
|
74
|
-
|
|
75
|
-
return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.rawListeners(e)) !== null && _b !== void 0 ? _b : [];
|
|
61
|
+
return this._origin?.rawListeners(e) ?? [];
|
|
76
62
|
}
|
|
77
63
|
/** @inheritDoc */
|
|
78
64
|
removeAllListeners(e) {
|
|
79
|
-
|
|
80
|
-
(_a = this._origin) === null || _a === void 0 ? void 0 : _a.removeAllListeners(e);
|
|
65
|
+
this._origin?.removeAllListeners(e);
|
|
81
66
|
return this;
|
|
82
67
|
}
|
|
83
68
|
/** @inheritDoc */
|
|
84
69
|
removeListener(e, l) {
|
|
85
|
-
|
|
86
|
-
(_a = this._origin) === null || _a === void 0 ? void 0 : _a.removeListener(e, l);
|
|
70
|
+
this._origin?.removeListener(e, l);
|
|
87
71
|
return this;
|
|
88
72
|
}
|
|
89
73
|
/** @inheritDoc */
|
|
90
74
|
setMaxListeners(m) {
|
|
91
|
-
|
|
92
|
-
(_a = this._origin) === null || _a === void 0 ? void 0 : _a.setMaxListeners(m);
|
|
75
|
+
this._origin?.setMaxListeners(m);
|
|
93
76
|
return this;
|
|
94
77
|
}
|
|
95
78
|
}
|
|
96
|
-
exports.HttpEvent = HttpEvent;
|
|
97
|
-
//# sourceMappingURL=http-event.js.map
|
package/dist/event/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './index.types';
|
|
2
|
-
export * from './http-event';
|
|
1
|
+
export * from './index.types.js';
|
|
2
|
+
export * from './http-event.js';
|