@innet/server 2.0.0-alpha.20 → 2.0.0-alpha.22
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 +138 -58
- package/handler/handler.d.ts +5 -7
- package/handler/handler.es6.js +4 -6
- package/handler/handler.js +4 -6
- package/index.es6.js +2 -3
- package/index.js +4 -6
- package/package.json +1 -1
- package/plugins/main/index.d.ts +1 -1
- package/plugins/main/index.es6.js +1 -1
- package/plugins/main/index.js +1 -1
- package/plugins/main/return/index.d.ts +1 -0
- package/plugins/main/return/index.es6.js +1 -0
- package/plugins/main/return/index.js +9 -0
- package/plugins/main/return/return.d.ts +4 -0
- package/plugins/main/{request/request.es6.js → return/return.es6.js} +2 -2
- package/plugins/main/{request/request.js → return/return.js} +2 -2
- package/plugins/utils/env/env.d.ts +6 -0
- package/plugins/utils/env/env.es6.js +11 -0
- package/plugins/utils/{dev/dev.js → env/env.js} +4 -3
- package/plugins/utils/env/index.d.ts +1 -0
- package/plugins/utils/env/index.es6.js +1 -0
- package/plugins/utils/{dev → env}/index.js +2 -2
- package/plugins/utils/index.d.ts +1 -2
- package/plugins/utils/index.es6.js +1 -2
- package/plugins/utils/index.js +1 -2
- package/plugins/main/request/index.d.ts +0 -1
- package/plugins/main/request/index.es6.js +0 -1
- package/plugins/main/request/index.js +0 -9
- package/plugins/main/request/request.d.ts +0 -4
- package/plugins/utils/dev/dev.d.ts +0 -4
- package/plugins/utils/dev/dev.es6.js +0 -10
- package/plugins/utils/dev/index.d.ts +0 -1
- package/plugins/utils/dev/index.es6.js +0 -1
- package/plugins/utils/prod/index.d.ts +0 -1
- package/plugins/utils/prod/index.es6.js +0 -1
- package/plugins/utils/prod/index.js +0 -9
- package/plugins/utils/prod/prod.d.ts +0 -4
- package/plugins/utils/prod/prod.es6.js +0 -10
- package/plugins/utils/prod/prod.js +0 -18
package/README.md
CHANGED
|
@@ -81,18 +81,18 @@ Here is a **Hello World** example:
|
|
|
81
81
|
```typescript jsx
|
|
82
82
|
export default (
|
|
83
83
|
<server>
|
|
84
|
-
<
|
|
84
|
+
<return>
|
|
85
85
|
<success>
|
|
86
86
|
Hello World!
|
|
87
87
|
</success>
|
|
88
|
-
</
|
|
88
|
+
</return>
|
|
89
89
|
</server>
|
|
90
90
|
)
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
*Use `npm start` to run this server.*
|
|
94
94
|
|
|
95
|
-
Open http://localhost
|
|
95
|
+
Open http://localhost
|
|
96
96
|
You will see the `Hello Word!` string.
|
|
97
97
|
|
|
98
98
|
---
|
|
@@ -110,7 +110,7 @@ export default (
|
|
|
110
110
|
|
|
111
111
|
*Use `npm start` to run this server.*
|
|
112
112
|
|
|
113
|
-
Open http://localhost
|
|
113
|
+
Open http://localhost
|
|
114
114
|
You will see a base Open API JSON structure.
|
|
115
115
|
|
|
116
116
|
```json
|
|
@@ -130,7 +130,7 @@ You will see a base Open API JSON structure.
|
|
|
130
130
|
|
|
131
131
|
[\<server>](#server)
|
|
132
132
|
[\<api>](#api)
|
|
133
|
-
[\<
|
|
133
|
+
[\<return>](#return)
|
|
134
134
|
[\<preset>](#preset)
|
|
135
135
|
|
|
136
136
|
---
|
|
@@ -376,41 +376,100 @@ export default (
|
|
|
376
376
|
)
|
|
377
377
|
```
|
|
378
378
|
|
|
379
|
-
### \<
|
|
379
|
+
### \<return>
|
|
380
380
|
|
|
381
381
|
[← back](#main)
|
|
382
382
|
|
|
383
383
|
This element MUST be placed in [\<server>](#server) element.
|
|
384
|
-
It defines run-time call handler for parent element.
|
|
384
|
+
It defines a run-time call handler for parent element.
|
|
385
385
|
|
|
386
386
|
*src/app.tsx*
|
|
387
387
|
```typescript jsx
|
|
388
388
|
export default (
|
|
389
389
|
<server>
|
|
390
|
-
<
|
|
390
|
+
<return>
|
|
391
391
|
<error status={404} />
|
|
392
|
-
</
|
|
392
|
+
</return>
|
|
393
393
|
</server>
|
|
394
394
|
)
|
|
395
395
|
```
|
|
396
396
|
*Any request returns 404*
|
|
397
397
|
|
|
398
|
-
|
|
398
|
+
The code runs from top to bottom and from left to right.
|
|
399
|
+
You cannot use two [\<return>](#return) elements one by one,
|
|
400
|
+
the same as you cannot use two `return` one by one for a JS `function`.
|
|
401
|
+
|
|
402
|
+
*src/app.tsx*
|
|
403
|
+
```typescript jsx
|
|
404
|
+
export default (
|
|
405
|
+
<server>
|
|
406
|
+
<return>
|
|
407
|
+
<error status={404} />
|
|
408
|
+
</return>
|
|
409
|
+
<return>
|
|
410
|
+
<success />
|
|
411
|
+
</return>
|
|
412
|
+
</server>
|
|
413
|
+
)
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
like
|
|
417
|
+
|
|
418
|
+
```javascript
|
|
419
|
+
function server () {
|
|
420
|
+
return 'error'
|
|
421
|
+
return 'success'
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
*The second [\<return>](#return) will newer run.*
|
|
426
|
+
|
|
427
|
+
You can use [\<return>](#return) in some elements like you use `return` in `if` or `while`.
|
|
428
|
+
|
|
429
|
+
*src/app.tsx*
|
|
430
|
+
```typescript jsx
|
|
431
|
+
export default (
|
|
432
|
+
<server>
|
|
433
|
+
<env is='dev'>
|
|
434
|
+
<return>
|
|
435
|
+
<error status={404} />
|
|
436
|
+
</return>
|
|
437
|
+
</env>
|
|
438
|
+
<return>
|
|
439
|
+
<success />
|
|
440
|
+
</return>
|
|
441
|
+
</server>
|
|
442
|
+
)
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
like
|
|
446
|
+
|
|
447
|
+
```javascript
|
|
448
|
+
function server () {
|
|
449
|
+
if (process.env.NODE_ENV === 'dev') {
|
|
450
|
+
return 'error'
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return 'success'
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
Place [\<return>](#return) in [\<api>](#api) to handle any unknown request in the [\<api>](#api).
|
|
399
458
|
|
|
400
459
|
*src/app.tsx*
|
|
401
460
|
```typescript jsx
|
|
402
461
|
export default (
|
|
403
462
|
<server>
|
|
404
463
|
<api>
|
|
405
|
-
<
|
|
464
|
+
<return>
|
|
406
465
|
<error status={404} />
|
|
407
|
-
</
|
|
466
|
+
</return>
|
|
408
467
|
</api>
|
|
409
468
|
</server>
|
|
410
469
|
)
|
|
411
470
|
```
|
|
412
471
|
|
|
413
|
-
Place [\<
|
|
472
|
+
Place [\<return>](#return) in [\<endpoint>](#endpoint) to handle the [\<endpoint>](#endpoint) request.
|
|
414
473
|
|
|
415
474
|
*src/app.tsx*
|
|
416
475
|
```typescript jsx
|
|
@@ -418,23 +477,23 @@ export default (
|
|
|
418
477
|
<server>
|
|
419
478
|
<api>
|
|
420
479
|
<endpoint method='get' path='/my-endpoint'>
|
|
421
|
-
<
|
|
480
|
+
<return>
|
|
422
481
|
<success>
|
|
423
482
|
My Endpoint
|
|
424
483
|
</success>
|
|
425
|
-
</
|
|
484
|
+
</return>
|
|
426
485
|
</endpoint>
|
|
427
486
|
</api>
|
|
428
|
-
<
|
|
487
|
+
<return>
|
|
429
488
|
<success>
|
|
430
489
|
Any other request
|
|
431
490
|
</success>
|
|
432
|
-
</
|
|
491
|
+
</return>
|
|
433
492
|
</server>
|
|
434
493
|
)
|
|
435
494
|
```
|
|
436
495
|
|
|
437
|
-
You can place a component inside [\<
|
|
496
|
+
You can place a component inside [\<return>](#return).
|
|
438
497
|
The component will run when the request will be triggered.
|
|
439
498
|
|
|
440
499
|
*src/app.tsx*
|
|
@@ -445,9 +504,9 @@ export default (
|
|
|
445
504
|
<server>
|
|
446
505
|
<api>
|
|
447
506
|
<endpoint method='get' path='/partners'>
|
|
448
|
-
<
|
|
507
|
+
<return>
|
|
449
508
|
<GetPartners />
|
|
450
|
-
</
|
|
509
|
+
</return>
|
|
451
510
|
</endpoint>
|
|
452
511
|
</api>
|
|
453
512
|
</server>
|
|
@@ -469,6 +528,8 @@ export const GetPartners = () => (
|
|
|
469
528
|
|
|
470
529
|
`<preset>` element MUST be placed in `<server>` element.
|
|
471
530
|
This element adds handling of each request.
|
|
531
|
+
It works the same as [\<return>](#return), but do not interrupt the running.
|
|
532
|
+
You can use it to add a `header` or `cookie` or some setup of a parent element.
|
|
472
533
|
|
|
473
534
|
*src/app.tsx*
|
|
474
535
|
```typescript jsx
|
|
@@ -497,7 +558,18 @@ export default (
|
|
|
497
558
|
value='no-cache, no-store, must-revalidate'
|
|
498
559
|
/>
|
|
499
560
|
</preset>
|
|
561
|
+
...Endpoints
|
|
562
|
+
<return>
|
|
563
|
+
<success>
|
|
564
|
+
Header contains `Cache-Control`
|
|
565
|
+
</success>
|
|
566
|
+
</return>
|
|
500
567
|
</api>
|
|
568
|
+
<return>
|
|
569
|
+
<success>
|
|
570
|
+
Header do not contain `Cache-Control`
|
|
571
|
+
</success>
|
|
572
|
+
</return>
|
|
501
573
|
</server>
|
|
502
574
|
)
|
|
503
575
|
```
|
|
@@ -509,8 +581,7 @@ This section contains elements of utils.
|
|
|
509
581
|
[← back](#index)
|
|
510
582
|
|
|
511
583
|
[\<swagger>](#swagger)
|
|
512
|
-
[\<
|
|
513
|
-
[\<prod>](#prod)
|
|
584
|
+
[\<env>](#env)
|
|
514
585
|
[\<dts>](#dts)
|
|
515
586
|
[\<blacklist>](#blacklist)
|
|
516
587
|
[\<whitelist>](#whitelist)
|
|
@@ -552,39 +623,48 @@ export default (
|
|
|
552
623
|
)
|
|
553
624
|
```
|
|
554
625
|
|
|
555
|
-
### \<
|
|
626
|
+
### \<env>
|
|
556
627
|
|
|
557
628
|
[← back](#utils)
|
|
558
629
|
|
|
559
|
-
|
|
630
|
+
This element helps to control content by `process.env`.
|
|
631
|
+
|
|
632
|
+
There are a required field of `is`.
|
|
633
|
+
If it's a `string` then an environment variable must be equal to the `string`.
|
|
634
|
+
If it's an `array of string` then an environment variable must be included into the `array of string`.
|
|
560
635
|
|
|
561
636
|
*src/app.tsx*
|
|
562
637
|
```typescript jsx
|
|
563
638
|
export default (
|
|
564
639
|
<server>
|
|
565
640
|
<api>
|
|
566
|
-
<dev>
|
|
641
|
+
<env is='dev'>
|
|
567
642
|
<swagger />
|
|
568
|
-
</
|
|
643
|
+
</env>
|
|
569
644
|
</api>
|
|
570
645
|
</server>
|
|
571
646
|
)
|
|
572
647
|
```
|
|
573
648
|
|
|
574
|
-
|
|
649
|
+
*The `<swagger />` will work only if `NODE_ENV` equals `dev`*
|
|
575
650
|
|
|
576
|
-
|
|
651
|
+
#### of
|
|
577
652
|
|
|
578
|
-
|
|
653
|
+
By default `of` equals `NODE_ENV`. You can check eny other environment variable.
|
|
579
654
|
|
|
580
655
|
*src/app.tsx*
|
|
581
656
|
```typescript jsx
|
|
582
657
|
export default (
|
|
583
658
|
<server>
|
|
584
659
|
<api>
|
|
585
|
-
<
|
|
660
|
+
<env
|
|
661
|
+
of='PORT'
|
|
662
|
+
is={[
|
|
663
|
+
'3000',
|
|
664
|
+
'8080',
|
|
665
|
+
]}>
|
|
586
666
|
<swagger />
|
|
587
|
-
</
|
|
667
|
+
</env>
|
|
588
668
|
</api>
|
|
589
669
|
</server>
|
|
590
670
|
)
|
|
@@ -3108,9 +3188,9 @@ export default (
|
|
|
3108
3188
|
<api>
|
|
3109
3189
|
<endpoint method='post' path='/users'>
|
|
3110
3190
|
<body>
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3191
|
+
<object
|
|
3192
|
+
description='The object of a user'
|
|
3193
|
+
/>
|
|
3114
3194
|
</body>
|
|
3115
3195
|
</endpoint>
|
|
3116
3196
|
</api>
|
|
@@ -3287,7 +3367,7 @@ export default (
|
|
|
3287
3367
|
[← back](#run-time)
|
|
3288
3368
|
|
|
3289
3369
|
Returns an error.
|
|
3290
|
-
This element MUST be placed in [\<
|
|
3370
|
+
This element MUST be placed in [\<return>](#return) or [\<response>](#response).
|
|
3291
3371
|
|
|
3292
3372
|
*src/app.tsx*
|
|
3293
3373
|
```typescript jsx
|
|
@@ -3413,7 +3493,7 @@ There are some default errors:
|
|
|
3413
3493
|
|
|
3414
3494
|
[← back](#run-time)
|
|
3415
3495
|
|
|
3416
|
-
MUST be placed in [\<
|
|
3496
|
+
MUST be placed in [\<return>](#return) or [\<response>](#response).
|
|
3417
3497
|
|
|
3418
3498
|
You can easy proxy endpoints to another server/service.
|
|
3419
3499
|
|
|
@@ -3425,9 +3505,9 @@ export default (
|
|
|
3425
3505
|
<endpoint
|
|
3426
3506
|
path='/test'
|
|
3427
3507
|
method='get'>
|
|
3428
|
-
<
|
|
3508
|
+
<return>
|
|
3429
3509
|
<proxy to='https://...' />
|
|
3430
|
-
</
|
|
3510
|
+
</return>
|
|
3431
3511
|
</endpoint>
|
|
3432
3512
|
</api>
|
|
3433
3513
|
<response>
|
|
@@ -3441,7 +3521,7 @@ export default (
|
|
|
3441
3521
|
|
|
3442
3522
|
[← back](#run-time)
|
|
3443
3523
|
|
|
3444
|
-
MUST be placed in [\<
|
|
3524
|
+
MUST be placed in [\<return>](#return) or [\<response>](#response).
|
|
3445
3525
|
|
|
3446
3526
|
You can redirect users to another resource. It adds `Cache-Control` header by default.
|
|
3447
3527
|
|
|
@@ -3453,14 +3533,14 @@ export default (
|
|
|
3453
3533
|
<endpoint
|
|
3454
3534
|
path='/test'
|
|
3455
3535
|
method='get'>
|
|
3456
|
-
<
|
|
3536
|
+
<return>
|
|
3457
3537
|
<redirect to='https://...' />
|
|
3458
|
-
</
|
|
3538
|
+
</return>
|
|
3459
3539
|
</endpoint>
|
|
3460
3540
|
</api>
|
|
3461
|
-
<
|
|
3541
|
+
<return>
|
|
3462
3542
|
<redirect to='https://...' />
|
|
3463
|
-
</
|
|
3543
|
+
</return>
|
|
3464
3544
|
</server>
|
|
3465
3545
|
)
|
|
3466
3546
|
```
|
|
@@ -3478,12 +3558,12 @@ export default (
|
|
|
3478
3558
|
<endpoint
|
|
3479
3559
|
path='/test'
|
|
3480
3560
|
method='get'>
|
|
3481
|
-
<
|
|
3561
|
+
<return>
|
|
3482
3562
|
<redirect
|
|
3483
3563
|
status='found'
|
|
3484
3564
|
to='https://...'
|
|
3485
3565
|
/>
|
|
3486
|
-
</
|
|
3566
|
+
</return>
|
|
3487
3567
|
</endpoint>
|
|
3488
3568
|
</api>
|
|
3489
3569
|
<response>
|
|
@@ -3500,7 +3580,7 @@ export default (
|
|
|
3500
3580
|
|
|
3501
3581
|
[← back](#run-time)
|
|
3502
3582
|
|
|
3503
|
-
MUST be placed in [\<
|
|
3583
|
+
MUST be placed in [\<return>](#return) or [\<response>](#response).
|
|
3504
3584
|
|
|
3505
3585
|
`<cms>` helps to return files from a folder by path. It checks files run-time on the server.
|
|
3506
3586
|
|
|
@@ -3596,7 +3676,7 @@ export default (
|
|
|
3596
3676
|
|
|
3597
3677
|
[← back](#run-time)
|
|
3598
3678
|
|
|
3599
|
-
It returns a file. MUST be placed in [\<
|
|
3679
|
+
It returns a file. MUST be placed in [\<return>](#return) or [\<response>](#response).
|
|
3600
3680
|
|
|
3601
3681
|
It adds `Content-Length` and `Content-Type` automatically.
|
|
3602
3682
|
|
|
@@ -3634,7 +3714,7 @@ export default (
|
|
|
3634
3714
|
|
|
3635
3715
|
### \<header>
|
|
3636
3716
|
|
|
3637
|
-
MUST be placed in [\<
|
|
3717
|
+
MUST be placed in [\<return>](#return) or [\<response>](#response).
|
|
3638
3718
|
|
|
3639
3719
|
[← back](#run-time)
|
|
3640
3720
|
|
|
@@ -3657,7 +3737,7 @@ export default (
|
|
|
3657
3737
|
|
|
3658
3738
|
### \<cookie>
|
|
3659
3739
|
|
|
3660
|
-
MUST be placed in [\<
|
|
3740
|
+
MUST be placed in [\<return>](#return) or [\<response>](#response).
|
|
3661
3741
|
|
|
3662
3742
|
[← back](#run-time)
|
|
3663
3743
|
|
|
@@ -3949,7 +4029,7 @@ Both
|
|
|
3949
4029
|
|
|
3950
4030
|
[← back](#hooks)
|
|
3951
4031
|
|
|
3952
|
-
This hook MUST be used in a component placed in [\<
|
|
4032
|
+
This hook MUST be used in a component placed in [\<return>](#return) or [\<response>](#response).
|
|
3953
4033
|
This hook returns current request instance.
|
|
3954
4034
|
|
|
3955
4035
|
*src/Component.tsx*
|
|
@@ -3970,7 +4050,7 @@ export function Component () {
|
|
|
3970
4050
|
|
|
3971
4051
|
[← back](#hooks)
|
|
3972
4052
|
|
|
3973
|
-
This hook MUST be used in a component placed in [\<
|
|
4053
|
+
This hook MUST be used in a component placed in [\<return>](#return) or [\<response>](#response).
|
|
3974
4054
|
This hook returns current response instance.
|
|
3975
4055
|
|
|
3976
4056
|
*src/Component.tsx*
|
|
@@ -3991,7 +4071,7 @@ export function Component () {
|
|
|
3991
4071
|
|
|
3992
4072
|
[← back](#hooks)
|
|
3993
4073
|
|
|
3994
|
-
This hook MUST be used in a component placed in [\<
|
|
4074
|
+
This hook MUST be used in a component placed in [\<return>](#return) or [\<response>](#response).
|
|
3995
4075
|
This hook returns current request headers object.
|
|
3996
4076
|
|
|
3997
4077
|
*src/Component.tsx*
|
|
@@ -4010,7 +4090,7 @@ export function Component () {
|
|
|
4010
4090
|
|
|
4011
4091
|
[← back](#hooks)
|
|
4012
4092
|
|
|
4013
|
-
This hook MUST be used in a component placed in [\<
|
|
4093
|
+
This hook MUST be used in a component placed in [\<return>](#return) or [\<response>](#response).
|
|
4014
4094
|
This hook returns current request cookies object.
|
|
4015
4095
|
|
|
4016
4096
|
*src/Component.tsx*
|
|
@@ -4029,7 +4109,7 @@ export function Component () {
|
|
|
4029
4109
|
|
|
4030
4110
|
[← back](#hooks)
|
|
4031
4111
|
|
|
4032
|
-
This hook MUST be used in a component placed in [\<
|
|
4112
|
+
This hook MUST be used in a component placed in [\<return>](#return) or [\<response>](#response).
|
|
4033
4113
|
This hook returns current request URL path as a `string`.
|
|
4034
4114
|
|
|
4035
4115
|
*src/Component.tsx*
|
|
@@ -4048,7 +4128,7 @@ export function Component () {
|
|
|
4048
4128
|
|
|
4049
4129
|
[← back](#hooks)
|
|
4050
4130
|
|
|
4051
|
-
This hook MUST be used in a component placed in [\<
|
|
4131
|
+
This hook MUST be used in a component placed in [\<return>](#return) or [\<response>](#response).
|
|
4052
4132
|
This hook returns an object of URL params you set by [\<param>](#param).
|
|
4053
4133
|
|
|
4054
4134
|
*src/Component.tsx*
|
|
@@ -4066,7 +4146,7 @@ export function Component () {
|
|
|
4066
4146
|
|
|
4067
4147
|
[← back](#hooks)
|
|
4068
4148
|
|
|
4069
|
-
This hook MUST be used in a component placed in [\<
|
|
4149
|
+
This hook MUST be used in a component placed in [\<return>](#return) or [\<response>](#response).
|
|
4070
4150
|
This hook returns an object of URL query params.
|
|
4071
4151
|
|
|
4072
4152
|
*src/Component.tsx*
|
|
@@ -4084,7 +4164,7 @@ export function Component () {
|
|
|
4084
4164
|
|
|
4085
4165
|
[← back](#hooks)
|
|
4086
4166
|
|
|
4087
|
-
This hook MUST be used in a component placed in [\<
|
|
4167
|
+
This hook MUST be used in a component placed in [\<return>](#return) or [\<response>](#response).
|
|
4088
4168
|
This hook returns current request body.
|
|
4089
4169
|
|
|
4090
4170
|
*src/Component.tsx*
|
|
@@ -4103,7 +4183,7 @@ export function Component () {
|
|
|
4103
4183
|
[← back](#hooks)
|
|
4104
4184
|
|
|
4105
4185
|
This hook returns request user IP.
|
|
4106
|
-
This hook MUST be used in a component placed in [\<
|
|
4186
|
+
This hook MUST be used in a component placed in [\<return>](#return) or [\<response>](#response).
|
|
4107
4187
|
|
|
4108
4188
|
*src/Component.tsx*
|
|
4109
4189
|
```typescript jsx
|
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 AnyProps, type ApiProps, type ArrayProps, type BinaryProps, blacklist, type BlacklistProps, type BodyProps, type BooleanProps, cms, type CmsProps, type ContactProps, type CookieProps, type DateProps, type
|
|
3
|
+
import { type AnyProps, type ApiProps, type ArrayProps, type BinaryProps, blacklist, type BlacklistProps, type BodyProps, type BooleanProps, cms, type CmsProps, type ContactProps, type CookieProps, type DateProps, type DtsProps, type EndpointProps, type EnvProps, type ErrorProps, type FieldProps, file, type FileProps, type HeaderProps, type HostProps, type IntegerProps, type LicenseProps, type NullProps, type NumberProps, type ObjectProps, type ParamProps, preset, type PresetProps, protection, type ProtectionProps, type ProxyProps, type RedirectProps, type ResponseProps, type ReturnProps, type ServerProps, type StringProps, type SuccessProps, type SwaggerProps, type TagProps, type TupleProps, type UuidProps, type VariableProps, whitelist, type WhitelistProps } from '../plugins';
|
|
4
4
|
export declare const arrayPlugins: (typeof arraySync)[];
|
|
5
5
|
export declare const JSXPlugins: {
|
|
6
6
|
any: import("innet").HandlerPlugin;
|
|
@@ -15,9 +15,9 @@ export declare const JSXPlugins: {
|
|
|
15
15
|
context: typeof context;
|
|
16
16
|
cookie: import("innet").HandlerPlugin;
|
|
17
17
|
date: import("innet").HandlerPlugin;
|
|
18
|
-
dev: import("innet").HandlerPlugin;
|
|
19
18
|
dts: import("innet").HandlerPlugin;
|
|
20
19
|
endpoint: import("innet").HandlerPlugin;
|
|
20
|
+
env: import("innet").HandlerPlugin;
|
|
21
21
|
error: import("innet").HandlerPlugin;
|
|
22
22
|
field: import("innet").HandlerPlugin;
|
|
23
23
|
file: typeof file;
|
|
@@ -30,12 +30,11 @@ export declare const JSXPlugins: {
|
|
|
30
30
|
object: import("innet").HandlerPlugin;
|
|
31
31
|
param: import("innet").HandlerPlugin;
|
|
32
32
|
preset: typeof preset;
|
|
33
|
-
prod: import("innet").HandlerPlugin;
|
|
34
33
|
protection: typeof protection;
|
|
35
34
|
proxy: import("innet").HandlerPlugin;
|
|
36
35
|
redirect: import("innet").HandlerPlugin;
|
|
37
|
-
request: import("innet").HandlerPlugin;
|
|
38
36
|
response: import("innet").HandlerPlugin;
|
|
37
|
+
return: import("innet").HandlerPlugin;
|
|
39
38
|
slot: typeof slot;
|
|
40
39
|
slots: typeof slots;
|
|
41
40
|
server: import("innet").HandlerPlugin;
|
|
@@ -67,9 +66,9 @@ declare global {
|
|
|
67
66
|
context: ContextProps;
|
|
68
67
|
cookie: CookieProps;
|
|
69
68
|
date: DateProps;
|
|
70
|
-
dev: DevProps;
|
|
71
69
|
dts: DtsProps;
|
|
72
70
|
endpoint: EndpointProps;
|
|
71
|
+
env: EnvProps;
|
|
73
72
|
error: ErrorProps;
|
|
74
73
|
field: FieldProps;
|
|
75
74
|
file: FileProps;
|
|
@@ -82,11 +81,10 @@ declare global {
|
|
|
82
81
|
object: ObjectProps;
|
|
83
82
|
param: ParamProps;
|
|
84
83
|
preset: PresetProps;
|
|
85
|
-
prod: ProdProps;
|
|
86
84
|
protection: ProtectionProps;
|
|
87
85
|
proxy: ProxyProps;
|
|
88
86
|
redirect: RedirectProps;
|
|
89
|
-
|
|
87
|
+
return: ReturnProps;
|
|
90
88
|
response: ResponseProps;
|
|
91
89
|
slot: SlotProps;
|
|
92
90
|
slots: SlotsProps;
|
package/handler/handler.es6.js
CHANGED
|
@@ -13,9 +13,9 @@ import { cms } from '../plugins/request/cms/cms.es6.js';
|
|
|
13
13
|
import { contact } from '../plugins/main/contact/contact.es6.js';
|
|
14
14
|
import { cookie } from '../plugins/request/cookie/cookie.es6.js';
|
|
15
15
|
import { date } from '../plugins/schema/date/date.es6.js';
|
|
16
|
-
import { dev } from '../plugins/utils/dev/dev.es6.js';
|
|
17
16
|
import { dts } from '../plugins/utils/dts/dts.es6.js';
|
|
18
17
|
import { endpoint } from '../plugins/main/endpoint/endpoint.es6.js';
|
|
18
|
+
import { env } from '../plugins/utils/env/env.es6.js';
|
|
19
19
|
import { error } from '../plugins/request/error/error.es6.js';
|
|
20
20
|
import { field } from '../plugins/schema/field/field.es6.js';
|
|
21
21
|
import { file } from '../plugins/request/file/file.es6.js';
|
|
@@ -28,12 +28,11 @@ import { number } from '../plugins/schema/number/number.es6.js';
|
|
|
28
28
|
import { object } from '../plugins/schema/object/object.es6.js';
|
|
29
29
|
import { param } from '../plugins/main/param/param.es6.js';
|
|
30
30
|
import { preset } from '../plugins/main/preset/preset.es6.js';
|
|
31
|
-
import { prod } from '../plugins/utils/prod/prod.es6.js';
|
|
32
31
|
import { protection } from '../plugins/utils/protection/protection.es6.js';
|
|
33
32
|
import { proxy } from '../plugins/request/proxy/proxy.es6.js';
|
|
34
33
|
import { redirect } from '../plugins/request/redirect/redirect.es6.js';
|
|
35
|
-
import { request } from '../plugins/main/request/request.es6.js';
|
|
36
34
|
import { response } from '../plugins/main/response/response.es6.js';
|
|
35
|
+
import { returnPlugin } from '../plugins/main/return/return.es6.js';
|
|
37
36
|
import { server } from '../plugins/main/server/server.es6.js';
|
|
38
37
|
import { swagger } from '../plugins/utils/swagger/swagger.es6.js';
|
|
39
38
|
import { string } from '../plugins/schema/string/string.es6.js';
|
|
@@ -61,9 +60,9 @@ const JSXPlugins = {
|
|
|
61
60
|
context,
|
|
62
61
|
cookie,
|
|
63
62
|
date,
|
|
64
|
-
dev,
|
|
65
63
|
dts,
|
|
66
64
|
endpoint,
|
|
65
|
+
env,
|
|
67
66
|
error,
|
|
68
67
|
field,
|
|
69
68
|
file,
|
|
@@ -76,12 +75,11 @@ const JSXPlugins = {
|
|
|
76
75
|
object,
|
|
77
76
|
param,
|
|
78
77
|
preset,
|
|
79
|
-
prod,
|
|
80
78
|
protection,
|
|
81
79
|
proxy,
|
|
82
80
|
redirect,
|
|
83
|
-
request,
|
|
84
81
|
response,
|
|
82
|
+
return: returnPlugin,
|
|
85
83
|
slot,
|
|
86
84
|
slots,
|
|
87
85
|
server,
|
package/handler/handler.js
CHANGED
|
@@ -17,9 +17,9 @@ var cms = require('../plugins/request/cms/cms.js');
|
|
|
17
17
|
var contact = require('../plugins/main/contact/contact.js');
|
|
18
18
|
var cookie = require('../plugins/request/cookie/cookie.js');
|
|
19
19
|
var date = require('../plugins/schema/date/date.js');
|
|
20
|
-
var dev = require('../plugins/utils/dev/dev.js');
|
|
21
20
|
var dts = require('../plugins/utils/dts/dts.js');
|
|
22
21
|
var endpoint = require('../plugins/main/endpoint/endpoint.js');
|
|
22
|
+
var env = require('../plugins/utils/env/env.js');
|
|
23
23
|
var error = require('../plugins/request/error/error.js');
|
|
24
24
|
var field = require('../plugins/schema/field/field.js');
|
|
25
25
|
var file = require('../plugins/request/file/file.js');
|
|
@@ -32,12 +32,11 @@ var number = require('../plugins/schema/number/number.js');
|
|
|
32
32
|
var object = require('../plugins/schema/object/object.js');
|
|
33
33
|
var param = require('../plugins/main/param/param.js');
|
|
34
34
|
var preset = require('../plugins/main/preset/preset.js');
|
|
35
|
-
var prod = require('../plugins/utils/prod/prod.js');
|
|
36
35
|
var protection = require('../plugins/utils/protection/protection.js');
|
|
37
36
|
var proxy = require('../plugins/request/proxy/proxy.js');
|
|
38
37
|
var redirect = require('../plugins/request/redirect/redirect.js');
|
|
39
|
-
var request = require('../plugins/main/request/request.js');
|
|
40
38
|
var response = require('../plugins/main/response/response.js');
|
|
39
|
+
var _return = require('../plugins/main/return/return.js');
|
|
41
40
|
var server = require('../plugins/main/server/server.js');
|
|
42
41
|
var swagger = require('../plugins/utils/swagger/swagger.js');
|
|
43
42
|
var string = require('../plugins/schema/string/string.js');
|
|
@@ -65,9 +64,9 @@ const JSXPlugins = {
|
|
|
65
64
|
context: jsx.context,
|
|
66
65
|
cookie: cookie.cookie,
|
|
67
66
|
date: date.date,
|
|
68
|
-
dev: dev.dev,
|
|
69
67
|
dts: dts.dts,
|
|
70
68
|
endpoint: endpoint.endpoint,
|
|
69
|
+
env: env.env,
|
|
71
70
|
error: error.error,
|
|
72
71
|
field: field.field,
|
|
73
72
|
file: file.file,
|
|
@@ -80,12 +79,11 @@ const JSXPlugins = {
|
|
|
80
79
|
object: object.object,
|
|
81
80
|
param: param.param,
|
|
82
81
|
preset: preset.preset,
|
|
83
|
-
prod: prod.prod,
|
|
84
82
|
protection: protection.protection,
|
|
85
83
|
proxy: proxy.proxy,
|
|
86
84
|
redirect: redirect.redirect,
|
|
87
|
-
request: request.request,
|
|
88
85
|
response: response.response,
|
|
86
|
+
return: _return.returnPlugin,
|
|
89
87
|
slot: jsx.slot,
|
|
90
88
|
slots: jsx.slots,
|
|
91
89
|
server: server.server,
|
package/index.es6.js
CHANGED
|
@@ -13,7 +13,7 @@ export { variable } from './plugins/main/variable/variable.es6.js';
|
|
|
13
13
|
export { tag } from './plugins/main/tag/tag.es6.js';
|
|
14
14
|
export { endpoint } from './plugins/main/endpoint/endpoint.es6.js';
|
|
15
15
|
export { response, statuses } from './plugins/main/response/response.es6.js';
|
|
16
|
-
export {
|
|
16
|
+
export { returnPlugin } from './plugins/main/return/return.es6.js';
|
|
17
17
|
export { param } from './plugins/main/param/param.es6.js';
|
|
18
18
|
export { body } from './plugins/main/body/body.es6.js';
|
|
19
19
|
export { preset } from './plugins/main/preset/preset.es6.js';
|
|
@@ -40,8 +40,7 @@ export { file } from './plugins/request/file/file.es6.js';
|
|
|
40
40
|
export { cms } from './plugins/request/cms/cms.es6.js';
|
|
41
41
|
export { swagger } from './plugins/utils/swagger/swagger.es6.js';
|
|
42
42
|
export { dts } from './plugins/utils/dts/dts.es6.js';
|
|
43
|
-
export {
|
|
44
|
-
export { prod } from './plugins/utils/prod/prod.es6.js';
|
|
43
|
+
export { env } from './plugins/utils/env/env.es6.js';
|
|
45
44
|
export { protection } from './plugins/utils/protection/protection.es6.js';
|
|
46
45
|
export { blacklist } from './plugins/utils/blacklist/blacklist.es6.js';
|
|
47
46
|
export { whitelist } from './plugins/utils/whitelist/whitelist.es6.js';
|
package/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var variable = require('./plugins/main/variable/variable.js');
|
|
|
17
17
|
var tag = require('./plugins/main/tag/tag.js');
|
|
18
18
|
var endpoint = require('./plugins/main/endpoint/endpoint.js');
|
|
19
19
|
var response = require('./plugins/main/response/response.js');
|
|
20
|
-
var
|
|
20
|
+
var _return = require('./plugins/main/return/return.js');
|
|
21
21
|
var param = require('./plugins/main/param/param.js');
|
|
22
22
|
var body = require('./plugins/main/body/body.js');
|
|
23
23
|
var preset = require('./plugins/main/preset/preset.js');
|
|
@@ -44,8 +44,7 @@ var file = require('./plugins/request/file/file.js');
|
|
|
44
44
|
var cms = require('./plugins/request/cms/cms.js');
|
|
45
45
|
var swagger = require('./plugins/utils/swagger/swagger.js');
|
|
46
46
|
var dts = require('./plugins/utils/dts/dts.js');
|
|
47
|
-
var
|
|
48
|
-
var prod = require('./plugins/utils/prod/prod.js');
|
|
47
|
+
var env = require('./plugins/utils/env/env.js');
|
|
49
48
|
var protection = require('./plugins/utils/protection/protection.js');
|
|
50
49
|
var blacklist = require('./plugins/utils/blacklist/blacklist.js');
|
|
51
50
|
var whitelist = require('./plugins/utils/whitelist/whitelist.js');
|
|
@@ -138,7 +137,7 @@ exports.tag = tag.tag;
|
|
|
138
137
|
exports.endpoint = endpoint.endpoint;
|
|
139
138
|
exports.response = response.response;
|
|
140
139
|
exports.statuses = response.statuses;
|
|
141
|
-
exports.
|
|
140
|
+
exports.returnPlugin = _return.returnPlugin;
|
|
142
141
|
exports.param = param.param;
|
|
143
142
|
exports.body = body.body;
|
|
144
143
|
exports.preset = preset.preset;
|
|
@@ -168,8 +167,7 @@ exports.file = file.file;
|
|
|
168
167
|
exports.cms = cms.cms;
|
|
169
168
|
exports.swagger = swagger.swagger;
|
|
170
169
|
exports.dts = dts.dts;
|
|
171
|
-
exports.
|
|
172
|
-
exports.prod = prod.prod;
|
|
170
|
+
exports.env = env.env;
|
|
173
171
|
exports.protection = protection.protection;
|
|
174
172
|
exports.blacklist = blacklist.blacklist;
|
|
175
173
|
exports.whitelist = whitelist.whitelist;
|
package/package.json
CHANGED
package/plugins/main/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import './variable/index.es6.js';
|
|
|
7
7
|
import './tag/index.es6.js';
|
|
8
8
|
import './endpoint/index.es6.js';
|
|
9
9
|
import './response/index.es6.js';
|
|
10
|
-
import './
|
|
10
|
+
import './return/index.es6.js';
|
|
11
11
|
import './param/index.es6.js';
|
|
12
12
|
import './body/index.es6.js';
|
|
13
13
|
import './preset/index.es6.js';
|
package/plugins/main/index.js
CHANGED
|
@@ -9,7 +9,7 @@ require('./variable/index.js');
|
|
|
9
9
|
require('./tag/index.js');
|
|
10
10
|
require('./endpoint/index.js');
|
|
11
11
|
require('./response/index.js');
|
|
12
|
-
require('./
|
|
12
|
+
require('./return/index.js');
|
|
13
13
|
require('./param/index.js');
|
|
14
14
|
require('./body/index.js');
|
|
15
15
|
require('./preset/index.js');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './return';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { returnPlugin } from './return.es6.js';
|
|
@@ -2,9 +2,9 @@ import { useChildren } from '@innet/jsx';
|
|
|
2
2
|
import '../../../hooks/index.es6.js';
|
|
3
3
|
import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.es6.js';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const returnPlugin = () => {
|
|
6
6
|
const children = useChildren();
|
|
7
7
|
useServerPlugin(() => children);
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export {
|
|
10
|
+
export { returnPlugin };
|
|
@@ -6,9 +6,9 @@ var jsx = require('@innet/jsx');
|
|
|
6
6
|
require('../../../hooks/index.js');
|
|
7
7
|
var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const returnPlugin = () => {
|
|
10
10
|
const children = jsx.useChildren();
|
|
11
11
|
useServerPlugin.useServerPlugin(() => children);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
exports.
|
|
14
|
+
exports.returnPlugin = returnPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import innet, { useHandler } from 'innet';
|
|
2
|
+
import { useProps, useChildren } from '@innet/jsx';
|
|
3
|
+
|
|
4
|
+
const env = () => {
|
|
5
|
+
const { of = 'NODE_ENV', is } = useProps();
|
|
6
|
+
if (Array.isArray(is) ? is.includes(process.env[of]) : process.env[of] === is) {
|
|
7
|
+
innet(useChildren(), useHandler());
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { env };
|
|
@@ -9,10 +9,11 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
|
|
10
10
|
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const env = () => {
|
|
13
|
+
const { of = 'NODE_ENV', is } = jsx.useProps();
|
|
14
|
+
if (Array.isArray(is) ? is.includes(process.env[of]) : process.env[of] === is) {
|
|
14
15
|
innet__default["default"](jsx.useChildren(), innet.useHandler());
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
exports.
|
|
19
|
+
exports.env = env;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './env';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { env } from './env.es6.js';
|
package/plugins/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import './swagger/index.es6.js';
|
|
2
2
|
import './dts/index.es6.js';
|
|
3
|
-
import './
|
|
4
|
-
import './prod/index.es6.js';
|
|
3
|
+
import './env/index.es6.js';
|
|
5
4
|
import './protection/index.es6.js';
|
|
6
5
|
import './blacklist/index.es6.js';
|
|
7
6
|
import './whitelist/index.es6.js';
|
package/plugins/utils/index.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './request';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { request } from './request.es6.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dev';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { dev } from './dev.es6.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './prod';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { prod } from './prod.es6.js';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var innet = require('innet');
|
|
6
|
-
var jsx = require('@innet/jsx');
|
|
7
|
-
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
11
|
-
|
|
12
|
-
const prod = () => {
|
|
13
|
-
if (process.env.NODE_ENV === 'production') {
|
|
14
|
-
innet__default["default"](jsx.useChildren(), innet.useHandler());
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
exports.prod = prod;
|