@innet/server 2.0.0-beta.4 → 2.0.0-beta.6
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 +335 -9
- package/handler/handler.d.ts +5 -2
- package/handler/handler.es6.js +2 -0
- package/handler/handler.js +2 -0
- package/hooks/index.d.ts +24 -24
- package/hooks/index.es6.js +24 -24
- package/hooks/index.js +24 -24
- package/index.d.ts +2 -2
- package/index.es6.js +87 -86
- package/index.js +198 -195
- package/package.json +3 -3
- package/plugins/index.d.ts +2 -2
- package/plugins/index.es6.js +2 -2
- package/plugins/index.js +2 -2
- package/plugins/main/index.d.ts +8 -8
- package/plugins/main/index.es6.js +8 -8
- package/plugins/main/index.js +8 -8
- package/plugins/request/index.d.ts +5 -5
- package/plugins/request/index.es6.js +5 -5
- package/plugins/request/index.js +5 -5
- package/plugins/schema/array/array.d.ts +3 -0
- package/plugins/schema/array/array.es6.js +10 -1
- package/plugins/schema/array/array.js +10 -1
- package/plugins/schema/field/field.d.ts +2 -0
- package/plugins/schema/field/field.es6.js +7 -1
- package/plugins/schema/field/field.js +7 -1
- package/plugins/schema/index.d.ts +8 -8
- package/plugins/schema/index.es6.js +8 -8
- package/plugins/schema/index.js +8 -8
- package/plugins/schema/integer/integer.d.ts +37 -0
- package/plugins/schema/integer/integer.es6.js +21 -7
- package/plugins/schema/integer/integer.js +21 -7
- package/plugins/schema/number/number.d.ts +32 -0
- package/plugins/schema/number/number.es6.js +21 -5
- package/plugins/schema/number/number.js +21 -5
- package/plugins/schema/string/string.d.ts +27 -0
- package/plugins/schema/string/string.es6.js +9 -3
- package/plugins/schema/string/string.js +9 -3
- package/plugins/utils/index.d.ts +3 -2
- package/plugins/utils/index.es6.js +3 -2
- package/plugins/utils/index.js +3 -2
- package/plugins/utils/swagger/swagger.d.ts +1 -0
- package/plugins/utils/swagger/swagger.es6.js +1 -0
- package/plugins/utils/swagger/swagger.js +1 -0
- package/plugins/utils/ui/index.d.ts +1 -0
- package/plugins/utils/ui/index.es6.js +1 -0
- package/plugins/utils/ui/index.js +10 -0
- package/plugins/utils/ui/rapidoc.html.es6.js +3 -0
- package/plugins/utils/ui/rapidoc.html.js +7 -0
- package/plugins/utils/ui/redoc.html.es6.js +3 -0
- package/plugins/utils/ui/redoc.html.js +7 -0
- package/plugins/utils/ui/scalar.html.es6.js +3 -0
- package/plugins/utils/ui/scalar.html.js +7 -0
- package/plugins/utils/ui/swagger.html.es6.js +3 -0
- package/plugins/utils/ui/swagger.html.js +7 -0
- package/plugins/utils/ui/ui.d.ts +13 -0
- package/plugins/utils/ui/ui.es6.js +45 -0
- package/plugins/utils/ui/ui.js +50 -0
- package/utils/index.d.ts +8 -8
- package/utils/index.es6.js +8 -8
- package/utils/index.js +8 -8
- package/utils/rules/index.d.ts +17 -17
- package/utils/rules/index.es6.js +17 -17
- package/utils/rules/index.js +18 -18
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var swagger = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <meta\n name=\"description\"\n content=\"SwaggerUI\"\n />\n <title>SwaggerUI</title>\n <link rel=\"stylesheet\" href=\"https://unpkg.com/swagger-ui-dist/swagger-ui.css\" />\n</head>\n<body>\n<div id=\"swagger-ui\"></div>\n<script src=\"https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js\" crossorigin></script>\n<script>\n window.onload = () => {\n window.ui = SwaggerUIBundle({\n url: \"{apiUrl}\",\n dom_id: '#swagger-ui',\n ...{params}\n });\n };\n</script>\n</body>\n</html>\n";
|
|
2
|
+
|
|
3
|
+
export { swagger as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var swagger = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <meta\n name=\"description\"\n content=\"SwaggerUI\"\n />\n <title>SwaggerUI</title>\n <link rel=\"stylesheet\" href=\"https://unpkg.com/swagger-ui-dist/swagger-ui.css\" />\n</head>\n<body>\n<div id=\"swagger-ui\"></div>\n<script src=\"https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js\" crossorigin></script>\n<script>\n window.onload = () => {\n window.ui = SwaggerUIBundle({\n url: \"{apiUrl}\",\n dom_id: '#swagger-ui',\n ...{params}\n });\n };\n</script>\n</body>\n</html>\n";
|
|
6
|
+
|
|
7
|
+
exports["default"] = swagger;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type HandlerPlugin } from 'innet';
|
|
2
|
+
export declare const uiPresets: {
|
|
3
|
+
rapidoc: string;
|
|
4
|
+
redoc: string;
|
|
5
|
+
scalar: string;
|
|
6
|
+
swagger: string;
|
|
7
|
+
};
|
|
8
|
+
export interface UiProps {
|
|
9
|
+
html?: string;
|
|
10
|
+
params?: Record<string, any>;
|
|
11
|
+
path?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const ui: HandlerPlugin;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { placeholder } from '@cantinc/utils';
|
|
2
|
+
import { useProps } from '@innet/jsx';
|
|
3
|
+
import '../../../hooks/index.es6.js';
|
|
4
|
+
import rapidoc from './rapidoc.html.es6.js';
|
|
5
|
+
import redoc from './redoc.html.es6.js';
|
|
6
|
+
import scalar from './scalar.html.es6.js';
|
|
7
|
+
import swagger from './swagger.html.es6.js';
|
|
8
|
+
import { useApi } from '../../../hooks/useApi/useApi.es6.js';
|
|
9
|
+
import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.es6.js';
|
|
10
|
+
import { useAction } from '../../../hooks/useAction/useAction.es6.js';
|
|
11
|
+
|
|
12
|
+
function camelToDash(str) {
|
|
13
|
+
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
14
|
+
}
|
|
15
|
+
const uiPresets = { rapidoc, redoc, scalar, swagger };
|
|
16
|
+
const ui = () => {
|
|
17
|
+
const { html = uiPresets.swagger, params = {}, path = process.env.INNET_UI_PATH || '/ui', } = useProps() || {};
|
|
18
|
+
const { docs, prefix, } = useApi();
|
|
19
|
+
let cache = '';
|
|
20
|
+
useServerPlugin(() => {
|
|
21
|
+
const action = useAction();
|
|
22
|
+
if (action.path === prefix + path) {
|
|
23
|
+
if (!cache) {
|
|
24
|
+
const attributes = Object
|
|
25
|
+
.keys(params)
|
|
26
|
+
.reduce((res, key) => {
|
|
27
|
+
return `${res} ${camelToDash(key)}='${String(params[key])}'`;
|
|
28
|
+
}, '');
|
|
29
|
+
cache = placeholder(html, {
|
|
30
|
+
apiUrl: prefix,
|
|
31
|
+
attributes,
|
|
32
|
+
docs: JSON.stringify(docs),
|
|
33
|
+
params: JSON.stringify(params),
|
|
34
|
+
...params,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
action.res.statusCode = 200;
|
|
38
|
+
action.res.write(cache);
|
|
39
|
+
action.res.end();
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { ui, uiPresets };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var utils = require('@cantinc/utils');
|
|
6
|
+
var jsx = require('@innet/jsx');
|
|
7
|
+
require('../../../hooks/index.js');
|
|
8
|
+
var rapidoc = require('./rapidoc.html.js');
|
|
9
|
+
var redoc = require('./redoc.html.js');
|
|
10
|
+
var scalar = require('./scalar.html.js');
|
|
11
|
+
var swagger = require('./swagger.html.js');
|
|
12
|
+
var useApi = require('../../../hooks/useApi/useApi.js');
|
|
13
|
+
var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
|
|
14
|
+
var useAction = require('../../../hooks/useAction/useAction.js');
|
|
15
|
+
|
|
16
|
+
function camelToDash(str) {
|
|
17
|
+
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
18
|
+
}
|
|
19
|
+
const uiPresets = { rapidoc: rapidoc["default"], redoc: redoc["default"], scalar: scalar["default"], swagger: swagger["default"] };
|
|
20
|
+
const ui = () => {
|
|
21
|
+
const { html = uiPresets.swagger, params = {}, path = process.env.INNET_UI_PATH || '/ui', } = jsx.useProps() || {};
|
|
22
|
+
const { docs, prefix, } = useApi.useApi();
|
|
23
|
+
let cache = '';
|
|
24
|
+
useServerPlugin.useServerPlugin(() => {
|
|
25
|
+
const action = useAction.useAction();
|
|
26
|
+
if (action.path === prefix + path) {
|
|
27
|
+
if (!cache) {
|
|
28
|
+
const attributes = Object
|
|
29
|
+
.keys(params)
|
|
30
|
+
.reduce((res, key) => {
|
|
31
|
+
return `${res} ${camelToDash(key)}='${String(params[key])}'`;
|
|
32
|
+
}, '');
|
|
33
|
+
cache = utils.placeholder(html, {
|
|
34
|
+
apiUrl: prefix,
|
|
35
|
+
attributes,
|
|
36
|
+
docs: JSON.stringify(docs),
|
|
37
|
+
params: JSON.stringify(params),
|
|
38
|
+
...params,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
action.res.statusCode = 200;
|
|
42
|
+
action.res.write(cache);
|
|
43
|
+
action.res.end();
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.ui = ui;
|
|
50
|
+
exports.uiPresets = uiPresets;
|
package/utils/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './FileData';
|
|
2
|
+
export * from './JSONString';
|
|
3
|
+
export * from './action';
|
|
4
|
+
export * from './decorators';
|
|
5
|
+
export * from './generateTypes';
|
|
4
6
|
export * from './getEndpoint';
|
|
5
7
|
export * from './getOrAdd';
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './action';
|
|
8
|
+
export * from './httpOnStart';
|
|
8
9
|
export * from './parseBody';
|
|
9
10
|
export * from './parseFormBody';
|
|
11
|
+
export * from './parseSearch';
|
|
10
12
|
export * from './rules';
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './FileData';
|
|
13
|
-
export * from './generateTypes';
|
|
13
|
+
export * from './stringifySearch';
|
package/utils/index.es6.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import './
|
|
2
|
-
import './
|
|
3
|
-
import './
|
|
1
|
+
import './FileData/index.es6.js';
|
|
2
|
+
import './JSONString/index.es6.js';
|
|
3
|
+
import './action/index.es6.js';
|
|
4
|
+
import './decorators/index.es6.js';
|
|
5
|
+
import './generateTypes/index.es6.js';
|
|
4
6
|
import './getEndpoint/index.es6.js';
|
|
5
7
|
import './getOrAdd/index.es6.js';
|
|
6
|
-
import './
|
|
7
|
-
import './action/index.es6.js';
|
|
8
|
+
import './httpOnStart/index.es6.js';
|
|
8
9
|
import './parseBody/index.es6.js';
|
|
9
10
|
import './parseFormBody/index.es6.js';
|
|
11
|
+
import './parseSearch/index.es6.js';
|
|
10
12
|
import './rules/index.es6.js';
|
|
11
|
-
import './
|
|
12
|
-
import './FileData/index.es6.js';
|
|
13
|
-
import './generateTypes/index.es6.js';
|
|
13
|
+
import './stringifySearch/index.es6.js';
|
package/utils/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./
|
|
4
|
-
require('./
|
|
5
|
-
require('./
|
|
3
|
+
require('./FileData/index.js');
|
|
4
|
+
require('./JSONString/index.js');
|
|
5
|
+
require('./action/index.js');
|
|
6
|
+
require('./decorators/index.js');
|
|
7
|
+
require('./generateTypes/index.js');
|
|
6
8
|
require('./getEndpoint/index.js');
|
|
7
9
|
require('./getOrAdd/index.js');
|
|
8
|
-
require('./
|
|
9
|
-
require('./action/index.js');
|
|
10
|
+
require('./httpOnStart/index.js');
|
|
10
11
|
require('./parseBody/index.js');
|
|
11
12
|
require('./parseFormBody/index.js');
|
|
13
|
+
require('./parseSearch/index.js');
|
|
12
14
|
require('./rules/index.js');
|
|
13
|
-
require('./
|
|
14
|
-
require('./FileData/index.js');
|
|
15
|
-
require('./generateTypes/index.js');
|
|
15
|
+
require('./stringifySearch/index.js');
|
|
16
16
|
|
package/utils/rules/index.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export * from './helpers';
|
|
2
|
-
export * from './constants';
|
|
3
|
-
export * from './types';
|
|
4
|
-
export * from './num';
|
|
5
1
|
export * from './arrayOf';
|
|
6
|
-
export * from './
|
|
2
|
+
export * from './bin';
|
|
3
|
+
export * from './binaryAccept';
|
|
4
|
+
export * from './constants';
|
|
7
5
|
export * from './dateTo';
|
|
6
|
+
export * from './defaultTo';
|
|
7
|
+
export * from './helpers';
|
|
8
8
|
export * from './int';
|
|
9
|
+
export * from './max';
|
|
10
|
+
export * from './maxBin';
|
|
11
|
+
export * from './maxDate';
|
|
12
|
+
export * from './maxLength';
|
|
13
|
+
export * from './min';
|
|
14
|
+
export * from './minBin';
|
|
15
|
+
export * from './minDate';
|
|
16
|
+
export * from './minLength';
|
|
9
17
|
export * from './nullable';
|
|
18
|
+
export * from './num';
|
|
10
19
|
export * from './objectOf';
|
|
20
|
+
export * from './oneOf';
|
|
11
21
|
export * from './optional';
|
|
12
22
|
export * from './pattern';
|
|
23
|
+
export * from './pipe';
|
|
13
24
|
export * from './required';
|
|
14
25
|
export * from './tupleOf';
|
|
26
|
+
export * from './types';
|
|
15
27
|
export * from './uuidTo';
|
|
16
28
|
export * from './values';
|
|
17
|
-
export * from './pipe';
|
|
18
|
-
export * from './maxDate';
|
|
19
|
-
export * from './minDate';
|
|
20
|
-
export * from './maxLength';
|
|
21
|
-
export * from './minLength';
|
|
22
|
-
export * from './max';
|
|
23
|
-
export * from './min';
|
|
24
|
-
export * from './defaultTo';
|
|
25
|
-
export * from './bin';
|
|
26
|
-
export * from './minBin';
|
|
27
|
-
export * from './maxBin';
|
|
28
|
-
export * from './binaryAccept';
|
package/utils/rules/index.es6.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export { RulesError, addKey } from './helpers.es6.js';
|
|
2
|
-
export { rulesErrors } from './constants.es6.js';
|
|
3
|
-
import './types.es6.js';
|
|
4
|
-
import './num/index.es6.js';
|
|
5
1
|
import './arrayOf/index.es6.js';
|
|
6
|
-
import './
|
|
2
|
+
import './bin/index.es6.js';
|
|
3
|
+
import './binaryAccept/index.es6.js';
|
|
4
|
+
export { rulesErrors } from './constants.es6.js';
|
|
7
5
|
import './dateTo/index.es6.js';
|
|
6
|
+
import './defaultTo/index.es6.js';
|
|
7
|
+
export { RulesError, addKey } from './helpers.es6.js';
|
|
8
8
|
import './int/index.es6.js';
|
|
9
|
+
import './max/index.es6.js';
|
|
10
|
+
import './maxBin/index.es6.js';
|
|
11
|
+
import './maxDate/index.es6.js';
|
|
12
|
+
import './maxLength/index.es6.js';
|
|
13
|
+
import './min/index.es6.js';
|
|
14
|
+
import './minBin/index.es6.js';
|
|
15
|
+
import './minDate/index.es6.js';
|
|
16
|
+
import './minLength/index.es6.js';
|
|
9
17
|
import './nullable/index.es6.js';
|
|
18
|
+
import './num/index.es6.js';
|
|
10
19
|
import './objectOf/index.es6.js';
|
|
20
|
+
import './oneOf/index.es6.js';
|
|
11
21
|
import './optional/index.es6.js';
|
|
12
22
|
import './pattern/index.es6.js';
|
|
23
|
+
import './pipe/index.es6.js';
|
|
13
24
|
import './required/index.es6.js';
|
|
14
25
|
import './tupleOf/index.es6.js';
|
|
26
|
+
import './types.es6.js';
|
|
15
27
|
import './uuidTo/index.es6.js';
|
|
16
28
|
import './values/index.es6.js';
|
|
17
|
-
import './pipe/index.es6.js';
|
|
18
|
-
import './maxDate/index.es6.js';
|
|
19
|
-
import './minDate/index.es6.js';
|
|
20
|
-
import './maxLength/index.es6.js';
|
|
21
|
-
import './minLength/index.es6.js';
|
|
22
|
-
import './max/index.es6.js';
|
|
23
|
-
import './min/index.es6.js';
|
|
24
|
-
import './defaultTo/index.es6.js';
|
|
25
|
-
import './bin/index.es6.js';
|
|
26
|
-
import './minBin/index.es6.js';
|
|
27
|
-
import './maxBin/index.es6.js';
|
|
28
|
-
import './binaryAccept/index.es6.js';
|
package/utils/rules/index.js
CHANGED
|
@@ -2,37 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var helpers = require('./helpers.js');
|
|
6
|
-
var constants = require('./constants.js');
|
|
7
|
-
require('./types.js');
|
|
8
|
-
require('./num/index.js');
|
|
9
5
|
require('./arrayOf/index.js');
|
|
10
|
-
require('./
|
|
6
|
+
require('./bin/index.js');
|
|
7
|
+
require('./binaryAccept/index.js');
|
|
8
|
+
var constants = require('./constants.js');
|
|
11
9
|
require('./dateTo/index.js');
|
|
10
|
+
require('./defaultTo/index.js');
|
|
11
|
+
var helpers = require('./helpers.js');
|
|
12
12
|
require('./int/index.js');
|
|
13
|
+
require('./max/index.js');
|
|
14
|
+
require('./maxBin/index.js');
|
|
15
|
+
require('./maxDate/index.js');
|
|
16
|
+
require('./maxLength/index.js');
|
|
17
|
+
require('./min/index.js');
|
|
18
|
+
require('./minBin/index.js');
|
|
19
|
+
require('./minDate/index.js');
|
|
20
|
+
require('./minLength/index.js');
|
|
13
21
|
require('./nullable/index.js');
|
|
22
|
+
require('./num/index.js');
|
|
14
23
|
require('./objectOf/index.js');
|
|
24
|
+
require('./oneOf/index.js');
|
|
15
25
|
require('./optional/index.js');
|
|
16
26
|
require('./pattern/index.js');
|
|
27
|
+
require('./pipe/index.js');
|
|
17
28
|
require('./required/index.js');
|
|
18
29
|
require('./tupleOf/index.js');
|
|
30
|
+
require('./types.js');
|
|
19
31
|
require('./uuidTo/index.js');
|
|
20
32
|
require('./values/index.js');
|
|
21
|
-
require('./pipe/index.js');
|
|
22
|
-
require('./maxDate/index.js');
|
|
23
|
-
require('./minDate/index.js');
|
|
24
|
-
require('./maxLength/index.js');
|
|
25
|
-
require('./minLength/index.js');
|
|
26
|
-
require('./max/index.js');
|
|
27
|
-
require('./min/index.js');
|
|
28
|
-
require('./defaultTo/index.js');
|
|
29
|
-
require('./bin/index.js');
|
|
30
|
-
require('./minBin/index.js');
|
|
31
|
-
require('./maxBin/index.js');
|
|
32
|
-
require('./binaryAccept/index.js');
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
exports.rulesErrors = constants.rulesErrors;
|
|
36
37
|
exports.RulesError = helpers.RulesError;
|
|
37
38
|
exports.addKey = helpers.addKey;
|
|
38
|
-
exports.rulesErrors = constants.rulesErrors;
|