@innet/server 2.0.0-alpha.9 → 2.0.0-beta.2
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 +1063 -445
- package/handler/handler.d.ts +23 -18
- package/handler/handler.es6.js +15 -14
- package/handler/handler.js +14 -13
- package/hooks/index.d.ts +6 -1
- package/hooks/index.es6.js +6 -1
- package/hooks/index.js +6 -1
- package/hooks/useAction/useAction.es6.js +1 -1
- package/hooks/useAction/useAction.js +1 -1
- package/hooks/useApi/useApi.d.ts +1 -3
- package/hooks/useClientIp/useClientIp.d.ts +1 -1
- package/hooks/useEndpoint/useEndpoint.d.ts +1 -1
- package/hooks/useEndpoint/useEndpoint.es6.js +3 -1
- package/hooks/useEndpoint/useEndpoint.js +3 -1
- package/hooks/useHeaders/useHeaders.d.ts +0 -1
- package/hooks/useIsServerHttps/index.d.ts +1 -0
- package/hooks/useIsServerHttps/index.es6.js +1 -0
- package/hooks/useIsServerHttps/index.js +10 -0
- package/hooks/useIsServerHttps/useIsServerHttps.d.ts +3 -0
- package/hooks/useIsServerHttps/useIsServerHttps.es6.js +14 -0
- package/hooks/useIsServerHttps/useIsServerHttps.js +19 -0
- package/hooks/useNewSchema/useNewSchema.es6.js +2 -2
- package/hooks/useNewSchema/useNewSchema.js +2 -2
- package/hooks/useObjectSchemaContext/index.d.ts +1 -0
- package/hooks/useObjectSchemaContext/index.es6.js +1 -0
- package/hooks/useObjectSchemaContext/index.js +10 -0
- package/hooks/useObjectSchemaContext/useObjectSchemaContext.d.ts +3 -0
- package/hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js +14 -0
- package/hooks/useObjectSchemaContext/useObjectSchemaContext.js +19 -0
- package/hooks/useRequest/index.es6.js +1 -1
- package/hooks/useRequest/index.js +0 -1
- package/hooks/useRequest/useRequest.d.ts +1 -5
- package/hooks/useRequest/useRequest.es6.js +4 -4
- package/hooks/useRequest/useRequest.js +3 -4
- package/hooks/useRequestHandler/index.d.ts +1 -0
- package/hooks/useRequestHandler/index.es6.js +1 -0
- package/hooks/useRequestHandler/index.js +10 -0
- package/hooks/useRequestHandler/useRequestHandler.d.ts +4 -0
- package/hooks/useRequestHandler/useRequestHandler.es6.js +14 -0
- package/hooks/useRequestHandler/useRequestHandler.js +19 -0
- package/hooks/useResponse/index.es6.js +1 -1
- package/hooks/useResponse/index.js +0 -1
- package/hooks/useResponse/useResponse.d.ts +1 -5
- package/hooks/useResponse/useResponse.es6.js +4 -4
- package/hooks/useResponse/useResponse.js +3 -4
- package/hooks/useSchemaType/useSchemaType.d.ts +3 -2
- package/hooks/useSchemaType/useSchemaType.es6.js +16 -9
- package/hooks/useSchemaType/useSchemaType.js +16 -9
- package/hooks/useServer/useServer.d.ts +2 -3
- package/hooks/useServer/useServer.es6.js +3 -1
- package/hooks/useServer/useServer.js +3 -1
- package/hooks/useServerPlugin/index.d.ts +1 -0
- package/hooks/useServerPlugin/index.es6.js +1 -0
- package/hooks/useServerPlugin/index.js +9 -0
- package/hooks/useServerPlugin/useServerPlugin.d.ts +2 -0
- package/hooks/useServerPlugin/useServerPlugin.es6.js +13 -0
- package/hooks/useServerPlugin/useServerPlugin.js +17 -0
- package/hooks/useServerPlugins/index.d.ts +1 -0
- package/hooks/useServerPlugins/index.es6.js +1 -0
- package/hooks/useServerPlugins/index.js +10 -0
- package/hooks/useServerPlugins/useServerPlugins.d.ts +4 -0
- package/hooks/useServerPlugins/useServerPlugins.es6.js +14 -0
- package/hooks/useServerPlugins/useServerPlugins.js +19 -0
- package/hooks/useServerPort/index.d.ts +1 -0
- package/hooks/useServerPort/index.es6.js +1 -0
- package/hooks/useServerPort/index.js +10 -0
- package/hooks/useServerPort/useServerPort.d.ts +3 -0
- package/hooks/useServerPort/useServerPort.es6.js +14 -0
- package/hooks/useServerPort/useServerPort.js +19 -0
- package/index.es6.js +15 -9
- package/index.js +30 -14
- package/package.json +15 -16
- package/plugins/handler/serverFn/serverFn.es6.js +1 -1
- package/plugins/handler/serverFn/serverFn.js +1 -1
- package/plugins/main/api/api.d.ts +11 -8
- package/plugins/main/api/api.es6.js +112 -113
- package/plugins/main/api/api.js +111 -112
- package/plugins/main/body/body.d.ts +1 -0
- package/plugins/main/contact/contact.d.ts +2 -2
- package/plugins/main/endpoint/endpoint.d.ts +21 -15
- package/plugins/main/endpoint/endpoint.es6.js +11 -9
- package/plugins/main/endpoint/endpoint.js +10 -8
- package/plugins/main/host/host.d.ts +5 -5
- package/plugins/main/host/host.es6.js +3 -1
- package/plugins/main/host/host.js +3 -1
- package/plugins/main/index.d.ts +2 -2
- package/plugins/main/index.es6.js +2 -2
- package/plugins/main/index.js +2 -2
- package/plugins/main/license/license.d.ts +5 -5
- package/plugins/main/param/param.d.ts +12 -11
- package/plugins/main/param/param.es6.js +6 -7
- package/plugins/main/param/param.js +5 -6
- package/plugins/main/preset/index.d.ts +1 -0
- package/plugins/main/preset/index.es6.js +1 -0
- package/plugins/{utils/prod → main/preset}/index.js +2 -2
- package/plugins/main/preset/preset.d.ts +3 -0
- package/plugins/main/preset/preset.es6.js +13 -0
- package/plugins/{utils/dev/dev.js → main/preset/preset.js} +9 -6
- package/plugins/main/response/index.es6.js +1 -1
- package/plugins/main/response/index.js +1 -0
- package/plugins/main/response/response.d.ts +6 -1
- package/plugins/main/response/response.es6.js +28 -12
- package/plugins/main/response/response.js +27 -10
- 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/return/return.es6.js +10 -0
- package/plugins/main/return/return.js +14 -0
- package/plugins/main/server/server.d.ts +6 -6
- package/plugins/main/server/server.es6.js +40 -16
- package/plugins/main/server/server.js +39 -15
- package/plugins/main/tag/tag.d.ts +3 -2
- package/plugins/main/tag/tag.es6.js +6 -4
- package/plugins/main/tag/tag.js +5 -3
- package/plugins/main/variable/variable.d.ts +5 -5
- package/plugins/main/variable/variable.es6.js +4 -3
- package/plugins/main/variable/variable.js +4 -3
- package/plugins/request/cms/cms.d.ts +1 -0
- package/plugins/request/cms/cms.es6.js +3 -4
- package/plugins/request/cms/cms.js +2 -3
- package/plugins/request/cookie/cookie.d.ts +2 -2
- package/plugins/request/cookie/cookie.es6.js +1 -2
- package/plugins/request/cookie/cookie.js +1 -2
- package/plugins/request/error/error.d.ts +41 -40
- package/plugins/request/error/error.es6.js +47 -45
- package/plugins/request/error/error.js +46 -44
- package/plugins/request/file/file.d.ts +1 -0
- package/plugins/request/file/file.es6.js +4 -6
- package/plugins/request/file/file.js +3 -5
- package/plugins/request/header/header.es6.js +1 -1
- package/plugins/request/header/header.js +1 -1
- package/plugins/request/proxy/proxy.d.ts +3 -1
- package/plugins/request/proxy/proxy.es6.js +5 -2
- package/plugins/request/proxy/proxy.js +5 -2
- package/plugins/request/redirect/redirect.d.ts +8 -7
- package/plugins/request/redirect/redirect.es6.js +7 -7
- package/plugins/request/redirect/redirect.js +7 -7
- package/plugins/request/success/success.d.ts +8 -6
- package/plugins/request/success/success.es6.js +21 -11
- package/plugins/request/success/success.js +20 -10
- package/plugins/schema/any/any.d.ts +5 -0
- package/plugins/schema/any/any.es6.js +27 -0
- package/plugins/schema/any/any.js +31 -0
- package/plugins/schema/array/array.d.ts +1 -0
- package/plugins/schema/array/array.es6.js +2 -3
- package/plugins/schema/array/array.js +1 -2
- package/plugins/schema/binary/binary.d.ts +3 -3
- package/plugins/schema/date/date.d.ts +1 -1
- package/plugins/schema/date/date.es6.js +8 -4
- package/plugins/schema/date/date.js +8 -4
- package/plugins/schema/field/field.d.ts +2 -0
- package/plugins/schema/field/field.es6.js +8 -8
- package/plugins/schema/field/field.js +6 -6
- package/plugins/schema/index.d.ts +1 -0
- package/plugins/schema/index.es6.js +1 -0
- package/plugins/schema/index.js +1 -0
- package/plugins/schema/integer/integer.d.ts +3 -3
- package/plugins/schema/integer/integer.es6.js +8 -3
- package/plugins/schema/integer/integer.js +8 -3
- package/plugins/schema/number/number.d.ts +2 -2
- package/plugins/schema/number/number.es6.js +1 -2
- package/plugins/schema/number/number.js +1 -2
- package/plugins/schema/object/object.d.ts +1 -0
- package/plugins/schema/object/object.es6.js +19 -7
- package/plugins/schema/object/object.js +18 -6
- package/plugins/schema/string/string.d.ts +2 -2
- package/plugins/schema/string/string.es6.js +44 -31
- package/plugins/schema/string/string.js +44 -31
- package/plugins/schema/tuple/tuple.d.ts +1 -0
- package/plugins/schema/tuple/tuple.es6.js +4 -5
- package/plugins/schema/tuple/tuple.js +3 -4
- package/plugins/schema/uuid/uuid.es6.js +5 -3
- package/plugins/schema/uuid/uuid.js +5 -3
- package/plugins/utils/blacklist/blacklist.d.ts +5 -0
- package/plugins/utils/blacklist/blacklist.es6.js +17 -0
- package/plugins/utils/blacklist/blacklist.js +21 -0
- package/plugins/utils/blacklist/index.d.ts +1 -0
- package/plugins/utils/blacklist/index.es6.js +1 -0
- package/plugins/utils/blacklist/index.js +9 -0
- package/plugins/utils/dts/dts.d.ts +2 -1
- package/plugins/utils/dts/dts.es6.js +2 -2
- package/plugins/utils/dts/dts.js +2 -2
- package/plugins/utils/env/env.d.ts +7 -0
- package/plugins/utils/env/env.es6.js +11 -0
- package/plugins/utils/{prod/prod.js → env/env.js} +5 -4
- 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 +3 -2
- package/plugins/utils/index.es6.js +3 -2
- package/plugins/utils/index.js +3 -2
- package/plugins/utils/protection/protection.d.ts +4 -4
- package/plugins/utils/protection/protection.es6.js +13 -16
- package/plugins/utils/protection/protection.js +13 -16
- package/plugins/utils/swagger/swagger.es6.js +7 -5
- package/plugins/utils/swagger/swagger.js +7 -5
- package/plugins/utils/whitelist/index.d.ts +1 -0
- package/plugins/utils/whitelist/index.es6.js +1 -0
- package/plugins/utils/whitelist/index.js +9 -0
- package/plugins/utils/whitelist/whitelist.d.ts +5 -0
- package/plugins/utils/whitelist/whitelist.es6.js +19 -0
- package/plugins/utils/whitelist/whitelist.js +23 -0
- package/types.d.ts +15 -22
- package/utils/FileData/Bin.d.ts +13 -13
- package/utils/FileData/Bin.es6.js +2 -2
- package/utils/FileData/Bin.js +2 -2
- package/utils/action/Action.d.ts +13 -14
- package/utils/action/Action.es6.js +92 -92
- package/utils/action/Action.js +91 -91
- package/utils/dateFormat/dateFormat.d.ts +1 -1
- package/utils/dateFormat/dateFormat.es6.js +1 -1
- package/utils/dateFormat/dateFormat.js +1 -1
- package/utils/decorators/once/once.es6.js +1 -1
- package/utils/decorators/once/once.js +1 -1
- package/utils/generateTypes/generateTypes.d.ts +2 -2
- package/utils/generateTypes/generateTypes.es6.js +85 -25
- package/utils/generateTypes/generateTypes.js +85 -25
- package/utils/getEndpoint/getEndpoint.es6.js +2 -2
- package/utils/getEndpoint/getEndpoint.js +2 -2
- package/utils/getOrAdd/getOrAdd.d.ts +1 -1
- package/utils/httpOnStart/httpOnStart.d.ts +1 -1
- package/utils/httpOnStart/httpOnStart.es6.js +1 -1
- package/utils/httpOnStart/httpOnStart.js +1 -1
- package/utils/parseBody/parseBody.d.ts +0 -1
- package/utils/parseBody/parseBody.es6.js +13 -16
- package/utils/parseBody/parseBody.js +13 -16
- package/utils/parseFormBody/parseFormBody.d.ts +0 -1
- package/utils/parseFormBody/parseFormBody.es6.js +41 -41
- package/utils/parseFormBody/parseFormBody.js +41 -41
- package/utils/parseSearch/parseSearch.es6.js +4 -1
- package/utils/parseSearch/parseSearch.js +4 -1
- package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
- package/utils/rules/arrayOf/arrayOf.js +1 -1
- package/utils/rules/bin/bin.es6.js +4 -1
- package/utils/rules/bin/bin.js +4 -1
- package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
- package/utils/rules/binaryAccept/binaryAccept.js +5 -2
- package/utils/rules/dateTo/dateTo.d.ts +1 -1
- package/utils/rules/dateTo/dateTo.es6.js +4 -1
- package/utils/rules/dateTo/dateTo.js +4 -1
- package/utils/rules/helpers.d.ts +1 -1
- package/utils/rules/helpers.es6.js +4 -1
- package/utils/rules/helpers.js +4 -1
- package/utils/rules/index.d.ts +0 -1
- package/utils/rules/index.es6.js +0 -1
- package/utils/rules/index.js +0 -1
- package/utils/rules/int/int.es6.js +17 -4
- package/utils/rules/int/int.js +17 -4
- package/utils/rules/max/max.d.ts +1 -1
- package/utils/rules/max/max.es6.js +10 -4
- package/utils/rules/max/max.js +10 -4
- package/utils/rules/maxBin/maxBin.es6.js +5 -2
- package/utils/rules/maxBin/maxBin.js +5 -2
- package/utils/rules/maxDate/maxDate.es6.js +5 -1
- package/utils/rules/maxDate/maxDate.js +5 -1
- package/utils/rules/maxLength/maxLength.es6.js +5 -2
- package/utils/rules/maxLength/maxLength.js +5 -2
- package/utils/rules/min/min.d.ts +1 -1
- package/utils/rules/min/min.es6.js +10 -4
- package/utils/rules/min/min.js +10 -4
- package/utils/rules/minBin/minBin.es6.js +5 -2
- package/utils/rules/minBin/minBin.js +5 -2
- package/utils/rules/minDate/minDate.es6.js +5 -1
- package/utils/rules/minDate/minDate.js +5 -1
- package/utils/rules/minLength/minLength.es6.js +5 -2
- package/utils/rules/minLength/minLength.js +5 -2
- package/utils/rules/num/num.es6.js +4 -1
- package/utils/rules/num/num.js +4 -1
- package/utils/rules/objectOf/objectOf.d.ts +1 -1
- package/utils/rules/objectOf/objectOf.es6.js +16 -3
- package/utils/rules/objectOf/objectOf.js +16 -3
- package/utils/rules/pattern/pattern.d.ts +1 -1
- package/utils/rules/pattern/pattern.es6.js +6 -1
- package/utils/rules/pattern/pattern.js +6 -1
- package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
- package/utils/rules/tupleOf/tupleOf.js +1 -1
- package/utils/rules/values/values.es6.js +5 -2
- package/utils/rules/values/values.js +5 -2
- package/utils/stringifySearch/stringifySearch.es6.js +4 -1
- package/utils/stringifySearch/stringifySearch.js +4 -1
- package/example/app/App/App.d.ts +0 -1
- package/example/app/App/index.d.ts +0 -1
- package/example/index.d.ts +0 -1
- package/example/requests/index.d.ts +0 -1
- package/example/requests/todo/AddTodo/AddTodo.d.ts +0 -1
- package/example/requests/todo/AddTodo/index.d.ts +0 -1
- package/example/requests/todo/DeleteTodo/DeleteTodo.d.ts +0 -1
- package/example/requests/todo/DeleteTodo/index.d.ts +0 -1
- package/example/requests/todo/EditTodo/EditTodo.d.ts +0 -1
- package/example/requests/todo/EditTodo/index.d.ts +0 -1
- package/example/requests/todo/GetTodo/GetTodo.d.ts +0 -1
- package/example/requests/todo/GetTodo/index.d.ts +0 -1
- package/example/requests/todo/GetTodos/GetTodos.d.ts +0 -1
- package/example/requests/todo/GetTodos/index.d.ts +0 -1
- package/example/requests/todo/index.d.ts +0 -5
- package/example/requests/todo/todos.d.ts +0 -1
- package/example/schemas/app/ListQueryParams/ListQueryParams.d.ts +0 -1
- package/example/schemas/app/ListQueryParams/index.d.ts +0 -1
- package/example/schemas/app/ListSchema/ListSchema.d.ts +0 -4
- package/example/schemas/app/ListSchema/index.d.ts +0 -1
- package/example/schemas/app/index.d.ts +0 -2
- package/example/schemas/index.d.ts +0 -2
- package/example/schemas/todo/TodoSchema/TodoSchema.d.ts +0 -4
- package/example/schemas/todo/TodoSchema/index.d.ts +0 -1
- package/example/schemas/todo/index.d.ts +0 -1
- package/example/tags/Todo/Todo.d.ts +0 -1
- package/example/tags/Todo/index.d.ts +0 -1
- package/example/tags/index.d.ts +0 -1
- package/hooks/useRequestPlugin/index.d.ts +0 -1
- package/hooks/useRequestPlugin/index.es6.js +0 -1
- package/hooks/useRequestPlugin/index.js +0 -9
- package/hooks/useRequestPlugin/useRequestPlugin.d.ts +0 -2
- package/hooks/useRequestPlugin/useRequestPlugin.es6.js +0 -13
- package/hooks/useRequestPlugin/useRequestPlugin.js +0 -17
- package/openApi.test.d.ts +0 -1
- package/plugins/main/fallback/fallback.d.ts +0 -4
- package/plugins/main/fallback/fallback.es6.js +0 -19
- package/plugins/main/fallback/fallback.js +0 -23
- package/plugins/main/fallback/index.d.ts +0 -1
- package/plugins/main/fallback/index.es6.js +0 -1
- package/plugins/main/fallback/index.js +0 -9
- 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/main/request/request.es6.js +0 -21
- package/plugins/main/request/request.js +0 -25
- 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/prod.d.ts +0 -4
- package/plugins/utils/prod/prod.es6.js +0 -10
- package/utils/decorators/once/once.test.d.ts +0 -1
- package/utils/generateTypes/generateTypes.test.d.ts +0 -1
- package/utils/parseSearch/parseSearch.test.d.ts +0 -1
- package/utils/rules/any/any.d.ts +0 -1
- package/utils/rules/any/any.es6.js +0 -5
- package/utils/rules/any/any.js +0 -9
- /package/{utils/rules → plugins/schema}/any/index.d.ts +0 -0
- /package/{utils/rules → plugins/schema}/any/index.es6.js +0 -0
- /package/{utils/rules → plugins/schema}/any/index.js +0 -0
package/plugins/main/api/api.js
CHANGED
|
@@ -2,63 +2,65 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib = require('tslib');
|
|
6
5
|
var innet = require('innet');
|
|
7
|
-
var
|
|
6
|
+
var jsx = require('@innet/jsx');
|
|
8
7
|
require('../../../hooks/index.js');
|
|
9
8
|
require('../../../utils/index.js');
|
|
10
9
|
require('../../../utils/rules/index.js');
|
|
11
|
-
var
|
|
10
|
+
var useServerPlugins = require('../../../hooks/useServerPlugins/useServerPlugins.js');
|
|
12
11
|
var useApi = require('../../../hooks/useApi/useApi.js');
|
|
13
|
-
var
|
|
12
|
+
var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
|
|
13
|
+
var useAction = require('../../../hooks/useAction/useAction.js');
|
|
14
14
|
var JSONString = require('../../../utils/JSONString/JSONString.js');
|
|
15
15
|
var helpers = require('../../../utils/rules/helpers.js');
|
|
16
|
-
var useResponse = require('../../../hooks/useResponse/useResponse.js');
|
|
17
|
-
var useRequest = require('../../../hooks/useRequest/useRequest.js');
|
|
18
16
|
var useParams = require('../../../hooks/useParams/useParams.js');
|
|
19
|
-
var useAction = require('../../../hooks/useAction/useAction.js');
|
|
20
17
|
|
|
21
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
19
|
|
|
23
20
|
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
24
21
|
|
|
25
22
|
const api = () => {
|
|
26
|
-
var _a;
|
|
27
23
|
const handler = innet.useNewHandler();
|
|
28
|
-
const
|
|
29
|
-
const {
|
|
30
|
-
const
|
|
31
|
-
const info = Object.assign(Object.assign({}, rest), { version: (_a = rest.version) !== null && _a !== void 0 ? _a : '0.0.0', title });
|
|
24
|
+
const props = jsx.useProps();
|
|
25
|
+
const { children, exclude, include, prefix = process.env.INNET_API_PREFIX || '', title = '', version = process.env.INNET_API_VERSION || '0.0.0', ...rest } = props;
|
|
26
|
+
const info = { ...rest, title, version };
|
|
32
27
|
const endpoints = {};
|
|
33
28
|
const docs = {
|
|
34
|
-
openapi: '3.1.0',
|
|
35
29
|
info,
|
|
30
|
+
openapi: '3.1.0',
|
|
36
31
|
paths: {},
|
|
37
32
|
};
|
|
38
|
-
const
|
|
39
|
-
const context = { docs, endpoints, prefix,
|
|
33
|
+
const plugins = new Set();
|
|
34
|
+
const context = { docs, endpoints, prefix, refRules: {} };
|
|
35
|
+
const condition = (action) => {
|
|
36
|
+
const path = action.parsedUrl.path;
|
|
37
|
+
const url = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
38
|
+
if (!url.startsWith(prefix) || (exclude === null || exclude === void 0 ? void 0 : exclude.test(url))) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (include && !include.test(url)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
useServerPlugins.serverPlugins.set(handler, plugins);
|
|
40
47
|
useApi.apiContext.set(handler, context);
|
|
41
|
-
|
|
42
|
-
var _b, _c, _d, _e, _f
|
|
43
|
-
|
|
48
|
+
useServerPlugin.useServerPlugin(async () => {
|
|
49
|
+
var _a, _b, _c, _d, _e, _f;
|
|
50
|
+
const action = useAction.useAction();
|
|
51
|
+
if (!condition(action))
|
|
44
52
|
return;
|
|
45
|
-
const
|
|
53
|
+
const actionHandler = innet.useNewHandler();
|
|
46
54
|
const path = action.parsedUrl.path;
|
|
47
55
|
const url = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
56
|
+
const { req, res, } = action;
|
|
48
57
|
if (url === (prefix || '')) {
|
|
49
58
|
res.setHeader('Content-Type', 'application/json');
|
|
50
59
|
res.write(JSONString.JSONString(docs));
|
|
51
60
|
res.end();
|
|
52
|
-
return;
|
|
61
|
+
return null;
|
|
53
62
|
}
|
|
54
|
-
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
for (const requestPlugin of requestPlugins) {
|
|
58
|
-
if (requestPlugin(action))
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const method = ((_c = (_b = req.method) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : 'get');
|
|
63
|
+
const method = ((_b = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : 'get');
|
|
62
64
|
const rawSplitPath = url.slice(prefix.length).split('/').slice(1);
|
|
63
65
|
const splitPath = rawSplitPath.at(-1) ? rawSplitPath : rawSplitPath.slice(0, -1);
|
|
64
66
|
const endpoint = endpoints[method];
|
|
@@ -67,121 +69,118 @@ const api = () => {
|
|
|
67
69
|
const [deep, currentEndpoint, params] = endpointQueue.shift();
|
|
68
70
|
const key = splitPath[deep];
|
|
69
71
|
if (deep + 1 === splitPath.length) {
|
|
70
|
-
function run(runEndpoint, params) {
|
|
72
|
+
async function run(runEndpoint, params) {
|
|
71
73
|
var _a, _b, _c, _d, _e;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
const pathRules = (_a = runEndpoint.rules) === null || _a === void 0 ? void 0 : _a.path;
|
|
75
|
+
const headerRules = (_b = runEndpoint.rules) === null || _b === void 0 ? void 0 : _b.header;
|
|
76
|
+
const cookieRules = (_c = runEndpoint.rules) === null || _c === void 0 ? void 0 : _c.cookie;
|
|
77
|
+
const searchRules = (_d = runEndpoint.rules) === null || _d === void 0 ? void 0 : _d.search;
|
|
78
|
+
const bodyRules = (_e = runEndpoint.rules) === null || _e === void 0 ? void 0 : _e.body;
|
|
79
|
+
if (pathRules) {
|
|
80
|
+
try {
|
|
81
|
+
Object.assign(params, pathRules(params, { in: 'path' }));
|
|
82
|
+
}
|
|
83
|
+
catch (_f) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function checkActionRules(rules, key = 'search') {
|
|
88
|
+
if (rules) {
|
|
79
89
|
try {
|
|
80
|
-
|
|
90
|
+
action[key] = rules(action[key]);
|
|
81
91
|
}
|
|
82
|
-
catch (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
catch (e) {
|
|
93
|
+
res.setHeader('Content-Type', 'application/json');
|
|
94
|
+
if (e instanceof helpers.RulesError) {
|
|
95
|
+
res.statusCode = 400;
|
|
96
|
+
res.write(JSONString.JSONString({
|
|
97
|
+
data: {
|
|
98
|
+
...e.data,
|
|
99
|
+
in: key,
|
|
100
|
+
},
|
|
101
|
+
error: 'requestValidation',
|
|
102
|
+
}));
|
|
103
|
+
res.end();
|
|
90
104
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
res.end();
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
console.error(e);
|
|
103
|
-
res.statusCode = 500;
|
|
104
|
-
res.write(JSONString.JSONString({
|
|
105
|
-
error: 'unknown',
|
|
106
|
-
data: { in: key },
|
|
107
|
-
}));
|
|
108
|
-
res.end();
|
|
109
|
-
}
|
|
110
|
-
return true;
|
|
105
|
+
else {
|
|
106
|
+
console.error(e);
|
|
107
|
+
res.statusCode = 500;
|
|
108
|
+
res.write(JSONString.JSONString({
|
|
109
|
+
data: { in: key },
|
|
110
|
+
error: 'unknown',
|
|
111
|
+
}));
|
|
112
|
+
res.end();
|
|
111
113
|
}
|
|
114
|
+
return true;
|
|
112
115
|
}
|
|
113
|
-
return false;
|
|
114
116
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (checkActionRules(headerRules, 'headers'))
|
|
120
|
+
return true;
|
|
121
|
+
if (checkActionRules(cookieRules, 'cookies'))
|
|
122
|
+
return true;
|
|
123
|
+
if (checkActionRules(searchRules, 'search'))
|
|
124
|
+
return true;
|
|
125
|
+
if (bodyRules) {
|
|
126
|
+
await action.parseBody();
|
|
127
|
+
if (!action.body) {
|
|
128
|
+
res.statusCode = 400;
|
|
129
|
+
res.setHeader('Content-Type', 'application/json');
|
|
130
|
+
res.write(JSONString.JSONString({
|
|
131
|
+
error: 'requestBodyContentType',
|
|
132
|
+
}));
|
|
133
|
+
res.end();
|
|
120
134
|
return true;
|
|
121
|
-
if (bodyRules) {
|
|
122
|
-
yield action.parseBody();
|
|
123
|
-
if (!action.body) {
|
|
124
|
-
res.statusCode = 400;
|
|
125
|
-
res.setHeader('Content-Type', 'application/json');
|
|
126
|
-
res.write(JSONString.JSONString({
|
|
127
|
-
error: 'requestBodyContentType',
|
|
128
|
-
}));
|
|
129
|
-
res.end();
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
if (checkActionRules(bodyRules, 'body'))
|
|
133
|
-
return true;
|
|
134
135
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
if (checkActionRules(bodyRules, 'body'))
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
useParams.paramsContext.set(actionHandler, params);
|
|
140
|
+
for (const plugin of runEndpoint.plugins) {
|
|
141
|
+
const result = await plugin();
|
|
142
|
+
if (result === undefined)
|
|
143
|
+
continue;
|
|
144
|
+
innet__default["default"](result, actionHandler);
|
|
141
145
|
return true;
|
|
142
|
-
}
|
|
146
|
+
}
|
|
147
|
+
return true;
|
|
143
148
|
}
|
|
144
|
-
if ((
|
|
145
|
-
if (!
|
|
149
|
+
if ((_d = (_c = currentEndpoint.static) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.plugins) {
|
|
150
|
+
if (!await run((_e = currentEndpoint.static) === null || _e === void 0 ? void 0 : _e[key], params))
|
|
146
151
|
continue;
|
|
147
|
-
return;
|
|
152
|
+
return null;
|
|
148
153
|
}
|
|
149
154
|
if (currentEndpoint.dynamic) {
|
|
150
155
|
for (const dynamicEndpoint of currentEndpoint.dynamic) {
|
|
151
|
-
if (dynamicEndpoint.
|
|
152
|
-
if (!
|
|
156
|
+
if (dynamicEndpoint.plugins) {
|
|
157
|
+
if (!await run(dynamicEndpoint, { ...params, [dynamicEndpoint.key.slice(1, -1)]: key }))
|
|
153
158
|
continue;
|
|
154
|
-
return;
|
|
159
|
+
return null;
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
162
|
}
|
|
158
163
|
break;
|
|
159
164
|
}
|
|
160
|
-
if ((
|
|
165
|
+
if ((_f = currentEndpoint.static) === null || _f === void 0 ? void 0 : _f[key]) {
|
|
161
166
|
endpointQueue.push([deep + 1, currentEndpoint.static[key], params]);
|
|
162
167
|
}
|
|
163
168
|
if (currentEndpoint.dynamic) {
|
|
164
169
|
for (const dynamicEndpoint of currentEndpoint.dynamic) {
|
|
165
|
-
endpointQueue.push([deep + 1, dynamicEndpoint,
|
|
170
|
+
endpointQueue.push([deep + 1, dynamicEndpoint, { ...params, [dynamicEndpoint.key.slice(1, -1)]: key }]);
|
|
166
171
|
}
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
for (const plugin of plugins) {
|
|
175
|
+
const result = await plugin();
|
|
176
|
+
if (result === undefined)
|
|
177
|
+
continue;
|
|
178
|
+
const newHandler = Object.create(handler);
|
|
173
179
|
useAction.actionContext.set(newHandler, action);
|
|
174
|
-
innet__default["default"](
|
|
175
|
-
|
|
176
|
-
else {
|
|
177
|
-
res.statusCode = 404;
|
|
178
|
-
res.end();
|
|
180
|
+
innet__default["default"](result, newHandler);
|
|
181
|
+
return null;
|
|
179
182
|
}
|
|
180
183
|
});
|
|
181
|
-
server.on('request', listener);
|
|
182
|
-
watchState.onDestroy(() => {
|
|
183
|
-
server.off('request', listener);
|
|
184
|
-
});
|
|
185
184
|
innet__default["default"](children, handler);
|
|
186
185
|
};
|
|
187
186
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
export interface ContactProps {
|
|
3
|
+
/** The email address of the contact person/organization. This MUST be in the form of an email address. */
|
|
4
|
+
email?: string;
|
|
3
5
|
/** The identifying name of the contact person/organization. */
|
|
4
6
|
name?: string;
|
|
5
7
|
/** The URL pointing to the contact information. This MUST be in the form of a URL. */
|
|
6
8
|
url?: string;
|
|
7
|
-
/** The email address of the contact person/organization. This MUST be in the form of an email address. */
|
|
8
|
-
email?: string;
|
|
9
9
|
}
|
|
10
10
|
export declare const contact: HandlerPlugin;
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type EndpointsMethods } from '../../../types';
|
|
3
3
|
export interface EndpointProps {
|
|
4
|
+
children?: any;
|
|
5
|
+
/**
|
|
6
|
+
* Declares this operation to be deprecated.
|
|
7
|
+
* Consumers SHOULD refrain from usage of the declared operation.
|
|
8
|
+
* Default value is false.
|
|
9
|
+
* */
|
|
10
|
+
deprecated?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* An optional, string description, intended to apply to all operations in this path.
|
|
13
|
+
* [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
|
|
14
|
+
* */
|
|
15
|
+
description?: string;
|
|
4
16
|
/**
|
|
5
17
|
* A method of the endpoint.
|
|
6
18
|
* */
|
|
7
19
|
method: EndpointsMethods;
|
|
20
|
+
/**
|
|
21
|
+
* `operationId` is an optional unique string used to identify an operation.
|
|
22
|
+
* If provided, these IDs must be unique among all operations described in your API.
|
|
23
|
+
* */
|
|
24
|
+
operationId?: string;
|
|
8
25
|
/**
|
|
9
26
|
* A relative path to an individual endpoint.
|
|
10
27
|
* The property MUST begin with a forward slash (/).
|
|
@@ -13,25 +30,14 @@ export interface EndpointProps {
|
|
|
13
30
|
* Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical.
|
|
14
31
|
* */
|
|
15
32
|
path: string;
|
|
16
|
-
/**
|
|
17
|
-
* An optional, string summary, intended to apply to all operations in this path.
|
|
18
|
-
* */
|
|
19
|
-
summary?: string;
|
|
20
|
-
/**
|
|
21
|
-
* An optional, string description, intended to apply to all operations in this path.
|
|
22
|
-
* [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
|
|
23
|
-
* */
|
|
24
|
-
description?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Declares this operation to be deprecated.
|
|
27
|
-
* Consumers SHOULD refrain from usage of the declared operation.
|
|
28
|
-
* Default value is false.
|
|
29
|
-
* */
|
|
30
|
-
deprecated?: boolean;
|
|
31
33
|
/**
|
|
32
34
|
* Declares this operation to make an endpoint private.
|
|
33
35
|
* That means the endpoint should not be described and will not be shown in the Open API documentation.
|
|
34
36
|
* */
|
|
35
37
|
private?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* An optional, string summary, intended to apply to all operations in this path.
|
|
40
|
+
* */
|
|
41
|
+
summary?: string;
|
|
36
42
|
}
|
|
37
43
|
export declare const endpoint: HandlerPlugin;
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import innet, { useNewHandler } from 'innet';
|
|
2
|
-
import { useProps
|
|
2
|
+
import { useProps } from '@innet/jsx';
|
|
3
3
|
import '../../../hooks/index.es6.js';
|
|
4
4
|
import '../../../utils/index.es6.js';
|
|
5
5
|
import { useTag } from '../../../hooks/useTag/useTag.es6.js';
|
|
6
6
|
import { useApi } from '../../../hooks/useApi/useApi.es6.js';
|
|
7
7
|
import { getEndpoint } from '../../../utils/getEndpoint/getEndpoint.es6.js';
|
|
8
8
|
import { endpointContext } from '../../../hooks/useEndpoint/useEndpoint.es6.js';
|
|
9
|
+
import { serverPlugins } from '../../../hooks/useServerPlugins/useServerPlugins.es6.js';
|
|
9
10
|
|
|
10
11
|
const endpoint = () => {
|
|
11
12
|
const handler = useNewHandler();
|
|
12
13
|
const tag = useTag();
|
|
13
|
-
const { docs, endpoints } = useApi();
|
|
14
14
|
const props = useProps();
|
|
15
|
-
const {
|
|
16
|
-
const children =
|
|
15
|
+
const { docs, endpoints, } = useApi();
|
|
16
|
+
const { children, deprecated, description, method, operationId, path, private: privateMode, summary, } = props;
|
|
17
17
|
const { paths } = docs;
|
|
18
18
|
if (!paths)
|
|
19
19
|
throw Error('cannot find paths in docs');
|
|
20
20
|
if (!paths[path]) {
|
|
21
21
|
paths[path] = {};
|
|
22
22
|
}
|
|
23
|
-
// @ts-expect-error: it's always an object
|
|
24
23
|
if (paths[path][method]) {
|
|
25
24
|
throw Error(`You cannot use the same endpoints ${method}:${path}`);
|
|
26
25
|
}
|
|
@@ -28,6 +27,9 @@ const endpoint = () => {
|
|
|
28
27
|
if (summary) {
|
|
29
28
|
operation.summary = summary;
|
|
30
29
|
}
|
|
30
|
+
if (operationId) {
|
|
31
|
+
operation.operationId = operationId;
|
|
32
|
+
}
|
|
31
33
|
if (description) {
|
|
32
34
|
operation.description = description;
|
|
33
35
|
}
|
|
@@ -38,16 +40,16 @@ const endpoint = () => {
|
|
|
38
40
|
operation.tags = [tag.name];
|
|
39
41
|
}
|
|
40
42
|
if (!privateMode) {
|
|
41
|
-
// @ts-expect-error: it's always an object
|
|
42
43
|
paths[path][method] = operation;
|
|
43
44
|
}
|
|
44
45
|
if (!endpoints[method]) {
|
|
45
|
-
endpoints[method] = { key: '' };
|
|
46
|
+
endpoints[method] = { key: '', plugins: new Set() };
|
|
46
47
|
}
|
|
47
|
-
// @ts-expect-error: it's always an object
|
|
48
48
|
const endpoint = getEndpoint(path, endpoints[method]);
|
|
49
49
|
// @ts-expect-error: it's always an object
|
|
50
|
-
endpointContext.set(handler, { operation, props
|
|
50
|
+
endpointContext.set(handler, { endpoint, operation, props });
|
|
51
|
+
// @ts-expect-error: it's always an object
|
|
52
|
+
serverPlugins.set(handler, endpoint.plugins);
|
|
51
53
|
innet(children, handler);
|
|
52
54
|
};
|
|
53
55
|
|
|
@@ -10,6 +10,7 @@ var useTag = require('../../../hooks/useTag/useTag.js');
|
|
|
10
10
|
var useApi = require('../../../hooks/useApi/useApi.js');
|
|
11
11
|
var getEndpoint = require('../../../utils/getEndpoint/getEndpoint.js');
|
|
12
12
|
var useEndpoint = require('../../../hooks/useEndpoint/useEndpoint.js');
|
|
13
|
+
var useServerPlugins = require('../../../hooks/useServerPlugins/useServerPlugins.js');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
16
|
|
|
@@ -18,17 +19,15 @@ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
|
18
19
|
const endpoint = () => {
|
|
19
20
|
const handler = innet.useNewHandler();
|
|
20
21
|
const tag = useTag.useTag();
|
|
21
|
-
const { docs, endpoints } = useApi.useApi();
|
|
22
22
|
const props = jsx.useProps();
|
|
23
|
-
const {
|
|
24
|
-
const children =
|
|
23
|
+
const { docs, endpoints, } = useApi.useApi();
|
|
24
|
+
const { children, deprecated, description, method, operationId, path, private: privateMode, summary, } = props;
|
|
25
25
|
const { paths } = docs;
|
|
26
26
|
if (!paths)
|
|
27
27
|
throw Error('cannot find paths in docs');
|
|
28
28
|
if (!paths[path]) {
|
|
29
29
|
paths[path] = {};
|
|
30
30
|
}
|
|
31
|
-
// @ts-expect-error: it's always an object
|
|
32
31
|
if (paths[path][method]) {
|
|
33
32
|
throw Error(`You cannot use the same endpoints ${method}:${path}`);
|
|
34
33
|
}
|
|
@@ -36,6 +35,9 @@ const endpoint = () => {
|
|
|
36
35
|
if (summary) {
|
|
37
36
|
operation.summary = summary;
|
|
38
37
|
}
|
|
38
|
+
if (operationId) {
|
|
39
|
+
operation.operationId = operationId;
|
|
40
|
+
}
|
|
39
41
|
if (description) {
|
|
40
42
|
operation.description = description;
|
|
41
43
|
}
|
|
@@ -46,16 +48,16 @@ const endpoint = () => {
|
|
|
46
48
|
operation.tags = [tag.name];
|
|
47
49
|
}
|
|
48
50
|
if (!privateMode) {
|
|
49
|
-
// @ts-expect-error: it's always an object
|
|
50
51
|
paths[path][method] = operation;
|
|
51
52
|
}
|
|
52
53
|
if (!endpoints[method]) {
|
|
53
|
-
endpoints[method] = { key: '' };
|
|
54
|
+
endpoints[method] = { key: '', plugins: new Set() };
|
|
54
55
|
}
|
|
55
|
-
// @ts-expect-error: it's always an object
|
|
56
56
|
const endpoint = getEndpoint.getEndpoint(path, endpoints[method]);
|
|
57
57
|
// @ts-expect-error: it's always an object
|
|
58
|
-
useEndpoint.endpointContext.set(handler, { operation, props
|
|
58
|
+
useEndpoint.endpointContext.set(handler, { endpoint, operation, props });
|
|
59
|
+
// @ts-expect-error: it's always an object
|
|
60
|
+
useServerPlugins.serverPlugins.set(handler, endpoint.plugins);
|
|
59
61
|
innet__default["default"](children, handler);
|
|
60
62
|
};
|
|
61
63
|
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
export interface HostProps {
|
|
3
|
+
/**
|
|
4
|
+
* An optional string describing the host designated by the URL.
|
|
5
|
+
* [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
|
|
6
|
+
* */
|
|
7
|
+
description?: string;
|
|
3
8
|
/**
|
|
4
9
|
* A URL to the target host.
|
|
5
10
|
* This URL supports Server Variables and MAY be relative,
|
|
@@ -7,10 +12,5 @@ export interface HostProps {
|
|
|
7
12
|
* Variable substitutions will be made when a variable is named in {brackets}.
|
|
8
13
|
* */
|
|
9
14
|
url: string;
|
|
10
|
-
/**
|
|
11
|
-
* An optional string describing the host designated by the URL.
|
|
12
|
-
* [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
|
|
13
|
-
* */
|
|
14
|
-
description?: string;
|
|
15
15
|
}
|
|
16
16
|
export declare const host: HandlerPlugin;
|
|
@@ -16,7 +16,9 @@ const host = () => {
|
|
|
16
16
|
target.servers = [];
|
|
17
17
|
}
|
|
18
18
|
const { servers } = operation || docs;
|
|
19
|
-
const server =
|
|
19
|
+
const server = {
|
|
20
|
+
...props,
|
|
21
|
+
};
|
|
20
22
|
// @ts-expect-error: FIXME
|
|
21
23
|
servers.push(server);
|
|
22
24
|
handler[hostContext.key] = { server };
|
|
@@ -24,7 +24,9 @@ const host = () => {
|
|
|
24
24
|
target.servers = [];
|
|
25
25
|
}
|
|
26
26
|
const { servers } = operation || docs;
|
|
27
|
-
const server =
|
|
27
|
+
const server = {
|
|
28
|
+
...props,
|
|
29
|
+
};
|
|
28
30
|
// @ts-expect-error: FIXME
|
|
29
31
|
servers.push(server);
|
|
30
32
|
handler[useHost.hostContext.key] = { server };
|
package/plugins/main/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export * from './variable';
|
|
|
7
7
|
export * from './tag';
|
|
8
8
|
export * from './endpoint';
|
|
9
9
|
export * from './response';
|
|
10
|
-
export * from './
|
|
10
|
+
export * from './return';
|
|
11
11
|
export * from './param';
|
|
12
12
|
export * from './body';
|
|
13
|
-
export * from './
|
|
13
|
+
export * from './preset';
|
|
@@ -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
|
-
import './
|
|
13
|
+
import './preset/index.es6.js';
|
package/plugins/main/index.js
CHANGED
|
@@ -9,8 +9,8 @@ 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
|
-
require('./
|
|
15
|
+
require('./preset/index.js');
|
|
16
16
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
export interface LicenseProps {
|
|
3
|
-
/**
|
|
4
|
-
* The license name used for the API.
|
|
5
|
-
* @example: Apache 2.0
|
|
6
|
-
* */
|
|
7
|
-
name: string;
|
|
8
3
|
/**
|
|
9
4
|
* An [SPDX](https://spdx.org/spdx-specification-21-web-version#h.jxpfx0ykyb60) license expression for the API.
|
|
10
5
|
* The `identifier` field is mutually exclusive of the `url` field.
|
|
11
6
|
* @example: Apache-2.0
|
|
12
7
|
* */
|
|
13
8
|
identifier?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The license name used for the API.
|
|
11
|
+
* @example: Apache 2.0
|
|
12
|
+
* */
|
|
13
|
+
name: string;
|
|
14
14
|
/**
|
|
15
15
|
* A URL to the license used for the API.
|
|
16
16
|
* This MUST be in the form of a URL.
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type InParam } from '../../../types';
|
|
3
3
|
export interface ParamProps {
|
|
4
|
+
children?: any;
|
|
5
|
+
/**
|
|
6
|
+
* Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
|
|
7
|
+
* Default value is `false`.
|
|
8
|
+
* */
|
|
9
|
+
deprecated?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* A brief description of the parameter.
|
|
12
|
+
* This could contain examples of use.
|
|
13
|
+
* [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
|
|
14
|
+
* */
|
|
15
|
+
description?: string;
|
|
4
16
|
/**
|
|
5
17
|
* The location of the parameter.
|
|
6
18
|
* Possible values are "query", "header", "path" or "cookie".
|
|
@@ -14,22 +26,11 @@ export interface ParamProps {
|
|
|
14
26
|
* - For all other cases, the `name` corresponds to the parameter name used by the `in` property.
|
|
15
27
|
* */
|
|
16
28
|
name: string;
|
|
17
|
-
/**
|
|
18
|
-
* A brief description of the parameter.
|
|
19
|
-
* This could contain examples of use.
|
|
20
|
-
* [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
|
|
21
|
-
* */
|
|
22
|
-
description?: string;
|
|
23
29
|
/**
|
|
24
30
|
* Determines whether this parameter is mandatory.
|
|
25
31
|
* If the parameter location is "path", this property is `true` and its value MUST be `true`.
|
|
26
32
|
* Otherwise, the property MAY be included and its default value is `false`.
|
|
27
33
|
* */
|
|
28
34
|
required?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
|
|
31
|
-
* Default value is `false`.
|
|
32
|
-
* */
|
|
33
|
-
deprecated?: boolean;
|
|
34
35
|
}
|
|
35
36
|
export declare const param: HandlerPlugin;
|