@innet/server 2.0.0-alpha.20 → 2.0.0-alpha.21
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 +19 -11
- package/handler/handler.d.ts +3 -5
- package/handler/handler.es6.js +2 -4
- package/handler/handler.js +2 -4
- package/index.es6.js +1 -2
- package/index.js +2 -4
- package/package.json +1 -1
- package/plugins/utils/env/env.d.ts +6 -0
- package/plugins/utils/env/env.es6.js +11 -0
- package/plugins/utils/{prod/prod.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/utils/dev/dev.d.ts +0 -4
- package/plugins/utils/dev/dev.es6.js +0 -10
- package/plugins/utils/dev/dev.js +0 -18
- 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/README.md
CHANGED
|
@@ -509,8 +509,7 @@ This section contains elements of utils.
|
|
|
509
509
|
[← back](#index)
|
|
510
510
|
|
|
511
511
|
[\<swagger>](#swagger)
|
|
512
|
-
[\<
|
|
513
|
-
[\<prod>](#prod)
|
|
512
|
+
[\<env>](#env)
|
|
514
513
|
[\<dts>](#dts)
|
|
515
514
|
[\<blacklist>](#blacklist)
|
|
516
515
|
[\<whitelist>](#whitelist)
|
|
@@ -552,39 +551,48 @@ export default (
|
|
|
552
551
|
)
|
|
553
552
|
```
|
|
554
553
|
|
|
555
|
-
### \<
|
|
554
|
+
### \<env>
|
|
556
555
|
|
|
557
556
|
[← back](#utils)
|
|
558
557
|
|
|
559
|
-
|
|
558
|
+
This element helps to control content by `process.env`.
|
|
559
|
+
|
|
560
|
+
There are a required field of `is`.
|
|
561
|
+
If it's a `string` then an environment variable must be equal to the `string`.
|
|
562
|
+
If it's an `array of string` then an environment variable must be included into the `array of string`.
|
|
560
563
|
|
|
561
564
|
*src/app.tsx*
|
|
562
565
|
```typescript jsx
|
|
563
566
|
export default (
|
|
564
567
|
<server>
|
|
565
568
|
<api>
|
|
566
|
-
<dev>
|
|
569
|
+
<env is='dev'>
|
|
567
570
|
<swagger />
|
|
568
|
-
</
|
|
571
|
+
</env>
|
|
569
572
|
</api>
|
|
570
573
|
</server>
|
|
571
574
|
)
|
|
572
575
|
```
|
|
573
576
|
|
|
574
|
-
|
|
577
|
+
*The `<swagger />` will work only if `NODE_ENV` equals `dev`*
|
|
575
578
|
|
|
576
|
-
|
|
579
|
+
#### of
|
|
577
580
|
|
|
578
|
-
|
|
581
|
+
By default `of` equals `NODE_ENV`. You can check eny other environment variable.
|
|
579
582
|
|
|
580
583
|
*src/app.tsx*
|
|
581
584
|
```typescript jsx
|
|
582
585
|
export default (
|
|
583
586
|
<server>
|
|
584
587
|
<api>
|
|
585
|
-
<
|
|
588
|
+
<env
|
|
589
|
+
of='PORT'
|
|
590
|
+
is={[
|
|
591
|
+
'3000',
|
|
592
|
+
'8080',
|
|
593
|
+
]}>
|
|
586
594
|
<swagger />
|
|
587
|
-
</
|
|
595
|
+
</env>
|
|
588
596
|
</api>
|
|
589
597
|
</server>
|
|
590
598
|
)
|
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 RequestProps, type ResponseProps, 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,7 +30,6 @@ 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;
|
|
@@ -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,7 +81,6 @@ 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;
|
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,7 +28,6 @@ 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';
|
|
@@ -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,7 +75,6 @@ const JSXPlugins = {
|
|
|
76
75
|
object,
|
|
77
76
|
param,
|
|
78
77
|
preset,
|
|
79
|
-
prod,
|
|
80
78
|
protection,
|
|
81
79
|
proxy,
|
|
82
80
|
redirect,
|
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,7 +32,6 @@ 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');
|
|
@@ -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,7 +79,6 @@ 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,
|
package/index.es6.js
CHANGED
|
@@ -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
|
@@ -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');
|
|
@@ -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
|
@@ -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
package/plugins/utils/dev/dev.js
DELETED
|
@@ -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 dev = () => {
|
|
13
|
-
if (process.env.NODE_ENV === 'development') {
|
|
14
|
-
innet__default["default"](jsx.useChildren(), innet.useHandler());
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
exports.dev = dev;
|
|
@@ -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';
|