@innet/server 2.0.0-alpha.0 → 2.0.0-alpha.10
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 +309 -29
- package/example/requests/index.d.ts +1 -1
- package/example/requests/todo/AddTodo/AddTodo.d.ts +1 -0
- package/example/requests/todo/AddTodo/index.d.ts +1 -0
- package/example/requests/todo/DeleteTodo/DeleteTodo.d.ts +1 -0
- package/example/requests/todo/DeleteTodo/index.d.ts +1 -0
- package/example/requests/todo/EditTodo/EditTodo.d.ts +1 -0
- package/example/requests/todo/EditTodo/index.d.ts +1 -0
- package/example/requests/todo/GetTodo/GetTodo.d.ts +1 -0
- package/example/requests/todo/GetTodo/index.d.ts +1 -0
- package/example/requests/todo/GetTodos/GetTodos.d.ts +1 -0
- package/example/requests/todo/GetTodos/index.d.ts +1 -0
- package/example/requests/todo/index.d.ts +5 -0
- package/example/requests/todo/todos.d.ts +1 -0
- package/example/schemas/app/ListQueryParams/ListQueryParams.d.ts +1 -0
- package/example/schemas/app/ListQueryParams/index.d.ts +1 -0
- package/example/schemas/app/ListSchema/ListSchema.d.ts +4 -1
- package/example/schemas/app/index.d.ts +1 -0
- package/example/schemas/index.d.ts +1 -3
- package/example/schemas/todo/TodoSchema/TodoSchema.d.ts +4 -0
- package/example/schemas/todo/TodoSchema/index.d.ts +1 -0
- package/example/schemas/todo/index.d.ts +1 -0
- package/example/tags/Todo/Todo.d.ts +1 -0
- package/example/tags/Todo/index.d.ts +1 -0
- package/example/tags/index.d.ts +1 -1
- package/handler/handler.d.ts +3 -1
- package/handler/handler.es6.js +2 -0
- package/handler/handler.js +2 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/index.es6.js +2 -0
- package/hooks/index.js +2 -0
- package/hooks/useClientIp/index.d.ts +1 -0
- package/hooks/useClientIp/index.es6.js +1 -0
- package/hooks/useClientIp/index.js +9 -0
- package/hooks/useClientIp/useClientIp.d.ts +1 -0
- package/hooks/useClientIp/useClientIp.es6.js +9 -0
- package/hooks/useClientIp/useClientIp.js +13 -0
- package/hooks/useComponentName/useComponentName.d.ts +1 -1
- package/hooks/useRequestPlugin/index.d.ts +1 -0
- package/hooks/useRequestPlugin/index.es6.js +1 -0
- package/hooks/useRequestPlugin/index.js +9 -0
- package/hooks/useRequestPlugin/useRequestPlugin.d.ts +2 -0
- package/hooks/useRequestPlugin/useRequestPlugin.es6.js +13 -0
- package/hooks/useRequestPlugin/useRequestPlugin.js +17 -0
- package/index.es6.js +4 -0
- package/index.js +9 -0
- package/package.json +2 -2
- package/plugins/main/api/api.es6.js +18 -11
- package/plugins/main/api/api.js +18 -11
- package/plugins/main/response/response.d.ts +1 -1
- package/plugins/main/response/response.es6.js +1 -1
- package/plugins/main/response/response.js +1 -1
- package/plugins/main/server/server.es6.js +10 -4
- package/plugins/main/server/server.js +10 -4
- package/plugins/request/cookie/cookie.es6.js +3 -19
- package/plugins/request/cookie/cookie.js +3 -23
- package/plugins/request/success/success.d.ts +1 -0
- package/plugins/request/success/success.es6.js +13 -4
- package/plugins/request/success/success.js +13 -4
- package/plugins/schema/boolean/boolean.es6.js +2 -4
- package/plugins/schema/boolean/boolean.js +1 -3
- package/plugins/utils/dts/dts.d.ts +1 -2
- package/plugins/utils/dts/dts.es6.js +6 -25
- package/plugins/utils/dts/dts.js +5 -29
- package/plugins/utils/index.d.ts +1 -0
- package/plugins/utils/index.es6.js +1 -0
- package/plugins/utils/index.js +1 -0
- package/plugins/utils/protection/index.d.ts +1 -0
- package/plugins/utils/protection/index.es6.js +1 -0
- package/plugins/utils/protection/index.js +9 -0
- package/plugins/utils/protection/protection.d.ts +8 -0
- package/plugins/utils/protection/protection.es6.js +34 -0
- package/plugins/utils/protection/protection.js +38 -0
- package/plugins/utils/swagger/swagger.es6.js +7 -11
- package/plugins/utils/swagger/swagger.js +7 -11
- package/types.d.ts +2 -3
- package/utils/action/Action.d.ts +7 -4
- package/utils/action/Action.es6.js +25 -3
- package/utils/action/Action.js +26 -4
- package/utils/generateTypes/generateTypes.d.ts +3 -0
- package/utils/generateTypes/generateTypes.es6.js +102 -0
- package/utils/generateTypes/generateTypes.js +107 -0
- package/utils/generateTypes/generateTypes.test.d.ts +1 -0
- package/utils/generateTypes/index.d.ts +1 -0
- package/utils/generateTypes/index.es6.js +1 -0
- package/utils/generateTypes/index.js +10 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.es6.js +1 -0
- package/utils/index.js +1 -0
- package/utils/rules/objectOf/objectOf.es6.js +4 -1
- package/utils/rules/objectOf/objectOf.js +4 -1
- package/example/requests/partners/EditPartner/EditPartner.d.ts +0 -1
- package/example/requests/partners/EditPartner/index.d.ts +0 -1
- package/example/requests/partners/GetPartner/GetPartner.d.ts +0 -1
- package/example/requests/partners/GetPartner/index.d.ts +0 -1
- package/example/requests/partners/GetPartners/GetPartners.d.ts +0 -1
- package/example/requests/partners/GetPartners/index.d.ts +0 -1
- package/example/requests/partners/index.d.ts +0 -3
- package/example/schemas/address/AddressSchema/AddressSchema.d.ts +0 -1
- package/example/schemas/address/AddressSchema/index.d.ts +0 -1
- package/example/schemas/address/index.d.ts +0 -1
- package/example/schemas/location/LocationSchema/LocationSchema.d.ts +0 -1
- package/example/schemas/location/LocationSchema/index.d.ts +0 -1
- package/example/schemas/location/index.d.ts +0 -1
- package/example/schemas/partner/EditPartnerSchema/EditPartnerSchema.d.ts +0 -1
- package/example/schemas/partner/EditPartnerSchema/index.d.ts +0 -1
- package/example/schemas/partner/PartnerSchema/PartnerSchema.d.ts +0 -1
- package/example/schemas/partner/PartnerSchema/index.d.ts +0 -1
- package/example/schemas/partner/index.d.ts +0 -2
- package/example/tags/Partner/Partner.d.ts +0 -1
- package/example/tags/Partner/index.d.ts +0 -1
package/README.md
CHANGED
|
@@ -317,7 +317,9 @@ This section contains elements of utils.
|
|
|
317
317
|
|
|
318
318
|
[\<swagger>](#swagger)
|
|
319
319
|
[\<dev>](#dev)
|
|
320
|
-
[\<
|
|
320
|
+
[\<prod>](#prod)
|
|
321
|
+
[\<dts>](#dts)
|
|
322
|
+
[\<protection>](#protection)
|
|
321
323
|
|
|
322
324
|
---
|
|
323
325
|
|
|
@@ -374,6 +376,25 @@ export default (
|
|
|
374
376
|
)
|
|
375
377
|
```
|
|
376
378
|
|
|
379
|
+
### \<prod>
|
|
380
|
+
|
|
381
|
+
[← back](#utils)
|
|
382
|
+
|
|
383
|
+
Everything inside <prod> will work when `NODE_ENV` equals `production`.
|
|
384
|
+
|
|
385
|
+
*src/app.tsx*
|
|
386
|
+
```typescript jsx
|
|
387
|
+
export default (
|
|
388
|
+
<server>
|
|
389
|
+
<api>
|
|
390
|
+
<prod>
|
|
391
|
+
<swagger />
|
|
392
|
+
</prod>
|
|
393
|
+
</api>
|
|
394
|
+
</server>
|
|
395
|
+
)
|
|
396
|
+
```
|
|
397
|
+
|
|
377
398
|
### \<dts>
|
|
378
399
|
|
|
379
400
|
[← back](#utils)
|
|
@@ -396,21 +417,170 @@ export default (
|
|
|
396
417
|
)
|
|
397
418
|
```
|
|
398
419
|
|
|
399
|
-
|
|
400
|
-
|
|
420
|
+
You do not need to import types, use `Api` namespace everywhere.
|
|
401
421
|
Here is an example of generated types usage.
|
|
402
422
|
|
|
403
|
-
*src/GetPartner.tsx*
|
|
404
423
|
```typescript jsx
|
|
405
424
|
import { useParams } from '@innet/server'
|
|
406
425
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
426
|
+
import { todos } from '../todos'
|
|
427
|
+
|
|
428
|
+
export function DeleteTodo () {
|
|
429
|
+
const { todoId } = useParams<Api.Endpoints['DELETE:/todos/{todoId}']['Params']>()
|
|
430
|
+
|
|
431
|
+
const todoIndex = todos.findIndex(({ id }) => id === todoId)
|
|
432
|
+
|
|
433
|
+
if (todoIndex === -1) {
|
|
434
|
+
return <error code='todoNotFound' status={404} />
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
todos.splice(todoIndex, 1)
|
|
438
|
+
|
|
439
|
+
return <success />
|
|
410
440
|
}
|
|
411
441
|
```
|
|
412
442
|
|
|
413
|
-
|
|
443
|
+
### \<protection>
|
|
444
|
+
|
|
445
|
+
This element MUST be placed in `<api>` element.
|
|
446
|
+
|
|
447
|
+
[← back](#utils)
|
|
448
|
+
|
|
449
|
+
This element adds protection page.
|
|
450
|
+
You can use it when you want to protect your application.
|
|
451
|
+
|
|
452
|
+
If protection failed content of the element should be used.
|
|
453
|
+
|
|
454
|
+
*src/app.tsx*
|
|
455
|
+
```typescript jsx
|
|
456
|
+
export default (
|
|
457
|
+
<server>
|
|
458
|
+
<api>
|
|
459
|
+
<protection>
|
|
460
|
+
<error
|
|
461
|
+
code='protection'
|
|
462
|
+
status='forbidden'
|
|
463
|
+
/>
|
|
464
|
+
</protection>
|
|
465
|
+
</api>
|
|
466
|
+
</server>
|
|
467
|
+
)
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
#### value
|
|
471
|
+
|
|
472
|
+
This prop is a secret string of protection value.
|
|
473
|
+
User must provide a protection query param equals the `value`.
|
|
474
|
+
|
|
475
|
+
By default, the value is `undefined` and protection does not work.
|
|
476
|
+
You can use `PROTECTION` env to set default protection `value`.
|
|
477
|
+
|
|
478
|
+
*src/app.tsx*
|
|
479
|
+
```typescript jsx
|
|
480
|
+
import html from './protection.html'
|
|
481
|
+
|
|
482
|
+
export default (
|
|
483
|
+
<server>
|
|
484
|
+
<api>
|
|
485
|
+
<protection
|
|
486
|
+
value='secret'
|
|
487
|
+
html={html}
|
|
488
|
+
/>
|
|
489
|
+
</api>
|
|
490
|
+
</server>
|
|
491
|
+
)
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
#### maxAge
|
|
495
|
+
|
|
496
|
+
This prop sets how much time protection is qualified.
|
|
497
|
+
|
|
498
|
+
By default, the prop equals a year.
|
|
499
|
+
You can use `PROTECTION_MAX_AGE` env to set default `maxAge`.
|
|
500
|
+
|
|
501
|
+
*src/app.tsx*
|
|
502
|
+
```typescript jsx
|
|
503
|
+
import html from './protection.html'
|
|
504
|
+
|
|
505
|
+
export default (
|
|
506
|
+
<server>
|
|
507
|
+
<api>
|
|
508
|
+
<protection
|
|
509
|
+
maxAge={24 * 60 * 60}
|
|
510
|
+
html={html}
|
|
511
|
+
/>
|
|
512
|
+
</api>
|
|
513
|
+
</server>
|
|
514
|
+
)
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
#### excludeIp
|
|
518
|
+
|
|
519
|
+
This prop sets a list of IP addresses (split by `,`) to ignore the protection.
|
|
520
|
+
|
|
521
|
+
You can use `PROTECTED_IP` env to set default `excludeIp`.
|
|
522
|
+
|
|
523
|
+
*src/app.tsx*
|
|
524
|
+
```typescript jsx
|
|
525
|
+
import html from './protection.html'
|
|
526
|
+
|
|
527
|
+
export default (
|
|
528
|
+
<server>
|
|
529
|
+
<api>
|
|
530
|
+
<protection
|
|
531
|
+
excludeIp='0.0.0.0,127.0.0.0'
|
|
532
|
+
html={html}
|
|
533
|
+
/>
|
|
534
|
+
</api>
|
|
535
|
+
</server>
|
|
536
|
+
)
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
#### cookieKey
|
|
540
|
+
|
|
541
|
+
This prop sets a cookie field name used to store protection of a user.
|
|
542
|
+
|
|
543
|
+
By default, it equals `protection`.
|
|
544
|
+
You can use `PROTECTION_COOKIE_KEY` env to set default `cookieKey`.
|
|
545
|
+
|
|
546
|
+
*src/app.tsx*
|
|
547
|
+
```typescript jsx
|
|
548
|
+
import html from './protection.html'
|
|
549
|
+
|
|
550
|
+
export default (
|
|
551
|
+
<server>
|
|
552
|
+
<api>
|
|
553
|
+
<protection
|
|
554
|
+
cookieKey='secret'
|
|
555
|
+
html={html}
|
|
556
|
+
/>
|
|
557
|
+
</api>
|
|
558
|
+
</server>
|
|
559
|
+
)
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
#### searchKey
|
|
563
|
+
|
|
564
|
+
This prop sets a search query field name used to check protection.
|
|
565
|
+
|
|
566
|
+
By default, it equals `protection`.
|
|
567
|
+
You can use `PROTECTION_SEARCH_KEY` env to set default `searchKey`.
|
|
568
|
+
|
|
569
|
+
*src/app.tsx*
|
|
570
|
+
```typescript jsx
|
|
571
|
+
import html from './protection.html'
|
|
572
|
+
|
|
573
|
+
export default (
|
|
574
|
+
<server>
|
|
575
|
+
<api>
|
|
576
|
+
<protection
|
|
577
|
+
searchKey='secret'
|
|
578
|
+
html={html}
|
|
579
|
+
/>
|
|
580
|
+
</api>
|
|
581
|
+
</server>
|
|
582
|
+
)
|
|
583
|
+
```
|
|
414
584
|
|
|
415
585
|
## API Info
|
|
416
586
|
|
|
@@ -2624,6 +2794,26 @@ export default (
|
|
|
2624
2794
|
)
|
|
2625
2795
|
```
|
|
2626
2796
|
|
|
2797
|
+
#### contentType
|
|
2798
|
+
|
|
2799
|
+
This props sets response content type.
|
|
2800
|
+
By default, it checks children element to define the prop.
|
|
2801
|
+
|
|
2802
|
+
*src/app.tsx*
|
|
2803
|
+
```typescript jsx
|
|
2804
|
+
export default (
|
|
2805
|
+
<server>
|
|
2806
|
+
<api>
|
|
2807
|
+
<fallback>
|
|
2808
|
+
<success contentType='text/html'>
|
|
2809
|
+
Hello World!
|
|
2810
|
+
</success>
|
|
2811
|
+
</fallback>
|
|
2812
|
+
</api>
|
|
2813
|
+
</server>
|
|
2814
|
+
)
|
|
2815
|
+
```
|
|
2816
|
+
|
|
2627
2817
|
### \<error>
|
|
2628
2818
|
|
|
2629
2819
|
[← back](#run-time)
|
|
@@ -3310,7 +3500,7 @@ Hook functions give you all features to control parent element functionality.
|
|
|
3310
3500
|
|
|
3311
3501
|
[← back](#index)
|
|
3312
3502
|
|
|
3313
|
-
|
|
3503
|
+
Real-time
|
|
3314
3504
|
[useRequest](#userequest)
|
|
3315
3505
|
[useResponse](#useresponse)
|
|
3316
3506
|
[useHeaders](#useheaders)
|
|
@@ -3319,29 +3509,16 @@ Hook functions give you all features to control parent element functionality.
|
|
|
3319
3509
|
[useParams](#useparams)
|
|
3320
3510
|
[useSearch](#usesearch)
|
|
3321
3511
|
[useBody](#usebody)
|
|
3512
|
+
[useClientIp](#useclientip)
|
|
3322
3513
|
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
### useServer
|
|
3326
|
-
|
|
3327
|
-
[← back](#hooks)
|
|
3328
|
-
|
|
3329
|
-
This hook MUST be used in a component placed in `<server>`.
|
|
3330
|
-
This hook returns current http(s) server instance.
|
|
3331
|
-
|
|
3332
|
-
*src/Component.tsx*
|
|
3333
|
-
|
|
3334
|
-
```typescript jsx
|
|
3335
|
-
import { useServer } from '@innet/sever'
|
|
3336
|
-
|
|
3337
|
-
export function Component () {
|
|
3338
|
-
const server = useServer()
|
|
3514
|
+
Server start
|
|
3515
|
+
[useRequestPlugin](#userequestplugin)
|
|
3339
3516
|
|
|
3340
|
-
|
|
3517
|
+
Both
|
|
3518
|
+
[useServer](#useserver)
|
|
3519
|
+
[useComponentName](#usecomponentname)
|
|
3341
3520
|
|
|
3342
|
-
|
|
3343
|
-
}
|
|
3344
|
-
```
|
|
3521
|
+
---
|
|
3345
3522
|
|
|
3346
3523
|
### useRequest
|
|
3347
3524
|
|
|
@@ -3496,6 +3673,109 @@ export function Component () {
|
|
|
3496
3673
|
}
|
|
3497
3674
|
```
|
|
3498
3675
|
|
|
3676
|
+
### useClientIp
|
|
3677
|
+
|
|
3678
|
+
[← back](#hooks)
|
|
3679
|
+
|
|
3680
|
+
This hook returns request user IP.
|
|
3681
|
+
This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
|
|
3682
|
+
|
|
3683
|
+
*src/Component.tsx*
|
|
3684
|
+
```typescript jsx
|
|
3685
|
+
import { useClientIp } from '@innet/sever'
|
|
3686
|
+
|
|
3687
|
+
export function Component () {
|
|
3688
|
+
const ip = useClientIp()
|
|
3689
|
+
|
|
3690
|
+
return <success>{{ ip }}</success>
|
|
3691
|
+
}
|
|
3692
|
+
```
|
|
3693
|
+
|
|
3694
|
+
### useRequestPlugin
|
|
3695
|
+
|
|
3696
|
+
[← back](#hooks)
|
|
3697
|
+
|
|
3698
|
+
This hook adds a request plugin function.
|
|
3699
|
+
The function runs before check endpoints.
|
|
3700
|
+
If the function returns `true` the request handling stops, and you get full control over the request.
|
|
3701
|
+
|
|
3702
|
+
This hook MUST be used in a component placed in [\<api>](#api).
|
|
3703
|
+
|
|
3704
|
+
*src/SecretEndpoint.tsx*
|
|
3705
|
+
```typescript jsx
|
|
3706
|
+
import { useRequestPlugin } from '@innet/sever'
|
|
3707
|
+
|
|
3708
|
+
export function SecretEndpoint () {
|
|
3709
|
+
useRequestPlugin((req, res) => {
|
|
3710
|
+
if (req.url.startsWith('/secret-endpoint')) {
|
|
3711
|
+
res.statusCode = 200
|
|
3712
|
+
res.write('A secret message')
|
|
3713
|
+
res.end()
|
|
3714
|
+
return true
|
|
3715
|
+
}
|
|
3716
|
+
})
|
|
3717
|
+
}
|
|
3718
|
+
```
|
|
3719
|
+
|
|
3720
|
+
Then use the plugin in [\<api>](#api).
|
|
3721
|
+
|
|
3722
|
+
*src/app.tsx*
|
|
3723
|
+
```typescript jsx
|
|
3724
|
+
import { SecretEndpoint } from './SecretEndpoint'
|
|
3725
|
+
|
|
3726
|
+
export default (
|
|
3727
|
+
<server>
|
|
3728
|
+
<api>
|
|
3729
|
+
<fallback>
|
|
3730
|
+
<error />
|
|
3731
|
+
</fallback>
|
|
3732
|
+
<SecretEndpoint />
|
|
3733
|
+
</api>
|
|
3734
|
+
</server>
|
|
3735
|
+
)
|
|
3736
|
+
```
|
|
3737
|
+
|
|
3738
|
+
Any endpoint returns an error except for `/secret-endpoint`.
|
|
3739
|
+
Elements order does not matter.
|
|
3740
|
+
|
|
3741
|
+
### useServer
|
|
3742
|
+
|
|
3743
|
+
[← back](#hooks)
|
|
3744
|
+
|
|
3745
|
+
This hook MUST be used in a component placed in [\<server>](#server).
|
|
3746
|
+
This hook returns current http(s) server instance.
|
|
3747
|
+
|
|
3748
|
+
*src/Component.tsx*
|
|
3749
|
+
```typescript jsx
|
|
3750
|
+
import { useServer } from '@innet/sever'
|
|
3751
|
+
|
|
3752
|
+
export function Component () {
|
|
3753
|
+
const server = useServer()
|
|
3754
|
+
|
|
3755
|
+
console.log(server)
|
|
3756
|
+
|
|
3757
|
+
return <success />
|
|
3758
|
+
}
|
|
3759
|
+
```
|
|
3760
|
+
|
|
3761
|
+
### useComponentName
|
|
3762
|
+
|
|
3763
|
+
[← back](#hooks)
|
|
3764
|
+
|
|
3765
|
+
This hook returns name of current component.
|
|
3766
|
+
|
|
3767
|
+
*src/Component.tsx*
|
|
3768
|
+
```typescript jsx
|
|
3769
|
+
import { useComponentName } from '@innet/sever'
|
|
3770
|
+
|
|
3771
|
+
export function Component () {
|
|
3772
|
+
// returns this ^-------^
|
|
3773
|
+
const name = useComponentName()
|
|
3774
|
+
|
|
3775
|
+
return <success>{{ name }}</success>
|
|
3776
|
+
}
|
|
3777
|
+
```
|
|
3778
|
+
|
|
3499
3779
|
## Issues
|
|
3500
3780
|
If you find a bug or have a suggestion, please file an issue on [GitHub](https://github.com/d8corp/innet-server/issues).
|
|
3501
3781
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './todo';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AddTodo(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AddTodo';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DeleteTodo(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DeleteTodo';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function EditTodo(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EditTodo';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function GetTodo(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GetTodo';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function GetTodos(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GetTodos';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const todos: Api.Schemas.TodoSchema[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ListQueryParams(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ListQueryParams';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TodoSchema';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TodoSchema';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Todo(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Todo';
|
package/example/tags/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './Todo';
|
package/handler/handler.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { context, type ContextProps, slot, type SlotProps, slots, type SlotsProps } from '@innet/jsx';
|
|
2
2
|
import { arraySync, async } from '@innet/utils';
|
|
3
|
-
import { type ApiProps, type ArrayProps, type BinaryProps, type BodyProps, type BooleanProps, cms, type CmsProps, type ContactProps, type CookieProps, type DateProps, type DevProps, type DtsProps, type EndpointProps, type ErrorProps, type FallbackProps, type FieldProps, file, type FileProps, type HeaderProps, type HostProps, type IntegerProps, type LicenseProps, type NullProps, type NumberProps, type ObjectProps, type ParamProps, type ProdProps, type ProxyProps, type RedirectProps, type RequestProps, type ResponseProps, type ServerProps, type StringProps, type SuccessProps, type SwaggerProps, type TagProps, type TupleProps, type UuidProps, type VariableProps } from '../plugins';
|
|
3
|
+
import { type ApiProps, type ArrayProps, type BinaryProps, type BodyProps, type BooleanProps, cms, type CmsProps, type ContactProps, type CookieProps, type DateProps, type DevProps, type DtsProps, type EndpointProps, type ErrorProps, type FallbackProps, type FieldProps, file, type FileProps, type HeaderProps, type HostProps, type IntegerProps, type LicenseProps, type NullProps, type NumberProps, type ObjectProps, type ParamProps, type ProdProps, protection, type ProtectionProps, type ProxyProps, type RedirectProps, type RequestProps, type ResponseProps, type ServerProps, type StringProps, type SuccessProps, type SwaggerProps, type TagProps, type TupleProps, type UuidProps, type VariableProps } from '../plugins';
|
|
4
4
|
export declare const arrayPlugins: (typeof arraySync)[];
|
|
5
5
|
export declare const JSXPlugins: {
|
|
6
6
|
api: import("innet").HandlerPlugin;
|
|
@@ -29,6 +29,7 @@ export declare const JSXPlugins: {
|
|
|
29
29
|
object: import("innet").HandlerPlugin;
|
|
30
30
|
param: import("innet").HandlerPlugin;
|
|
31
31
|
prod: import("innet").HandlerPlugin;
|
|
32
|
+
protection: typeof protection;
|
|
32
33
|
proxy: import("innet").HandlerPlugin;
|
|
33
34
|
redirect: import("innet").HandlerPlugin;
|
|
34
35
|
request: import("innet").HandlerPlugin;
|
|
@@ -77,6 +78,7 @@ declare global {
|
|
|
77
78
|
object: ObjectProps;
|
|
78
79
|
param: ParamProps;
|
|
79
80
|
prod: ProdProps;
|
|
81
|
+
protection: ProtectionProps;
|
|
80
82
|
proxy: ProxyProps;
|
|
81
83
|
redirect: RedirectProps;
|
|
82
84
|
request: RequestProps;
|
package/handler/handler.es6.js
CHANGED
|
@@ -27,6 +27,7 @@ import { number } from '../plugins/schema/number/number.es6.js';
|
|
|
27
27
|
import { object } from '../plugins/schema/object/object.es6.js';
|
|
28
28
|
import { param } from '../plugins/main/param/param.es6.js';
|
|
29
29
|
import { prod } from '../plugins/utils/prod/prod.es6.js';
|
|
30
|
+
import { protection } from '../plugins/utils/protection/protection.es6.js';
|
|
30
31
|
import { proxy } from '../plugins/request/proxy/proxy.es6.js';
|
|
31
32
|
import { redirect } from '../plugins/request/redirect/redirect.es6.js';
|
|
32
33
|
import { request } from '../plugins/main/request/request.es6.js';
|
|
@@ -71,6 +72,7 @@ const JSXPlugins = {
|
|
|
71
72
|
object,
|
|
72
73
|
param,
|
|
73
74
|
prod,
|
|
75
|
+
protection,
|
|
74
76
|
proxy,
|
|
75
77
|
redirect,
|
|
76
78
|
request,
|
package/handler/handler.js
CHANGED
|
@@ -31,6 +31,7 @@ var number = require('../plugins/schema/number/number.js');
|
|
|
31
31
|
var object = require('../plugins/schema/object/object.js');
|
|
32
32
|
var param = require('../plugins/main/param/param.js');
|
|
33
33
|
var prod = require('../plugins/utils/prod/prod.js');
|
|
34
|
+
var protection = require('../plugins/utils/protection/protection.js');
|
|
34
35
|
var proxy = require('../plugins/request/proxy/proxy.js');
|
|
35
36
|
var redirect = require('../plugins/request/redirect/redirect.js');
|
|
36
37
|
var request = require('../plugins/main/request/request.js');
|
|
@@ -75,6 +76,7 @@ const JSXPlugins = {
|
|
|
75
76
|
object: object.object,
|
|
76
77
|
param: param.param,
|
|
77
78
|
prod: prod.prod,
|
|
79
|
+
protection: protection.protection,
|
|
78
80
|
proxy: proxy.proxy,
|
|
79
81
|
redirect: redirect.redirect,
|
|
80
82
|
request: request.request,
|
package/hooks/index.d.ts
CHANGED
package/hooks/index.es6.js
CHANGED
package/hooks/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useClientIp';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useClientIp } from './useClientIp.es6.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useClientIp(): string | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../useAction/index.js');
|
|
6
|
+
var useAction = require('../useAction/useAction.js');
|
|
7
|
+
|
|
8
|
+
function useClientIp() {
|
|
9
|
+
const action = useAction.useAction();
|
|
10
|
+
return action.clientIp;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.useClientIp = useClientIp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useComponentName():
|
|
1
|
+
export declare function useComponentName(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useRequestPlugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useRequestPlugin } from './useRequestPlugin.es6.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { onDestroy } from 'watch-state';
|
|
2
|
+
import '../useApi/index.es6.js';
|
|
3
|
+
import { useApi } from '../useApi/useApi.es6.js';
|
|
4
|
+
|
|
5
|
+
function useRequestPlugin(listener) {
|
|
6
|
+
const { requestPlugins } = useApi();
|
|
7
|
+
requestPlugins.add(listener);
|
|
8
|
+
onDestroy(() => {
|
|
9
|
+
requestPlugins.delete(listener);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { useRequestPlugin };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var watchState = require('watch-state');
|
|
6
|
+
require('../useApi/index.js');
|
|
7
|
+
var useApi = require('../useApi/useApi.js');
|
|
8
|
+
|
|
9
|
+
function useRequestPlugin(listener) {
|
|
10
|
+
const { requestPlugins } = useApi.useApi();
|
|
11
|
+
requestPlugins.add(listener);
|
|
12
|
+
watchState.onDestroy(() => {
|
|
13
|
+
requestPlugins.delete(listener);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.useRequestPlugin = useRequestPlugin;
|