@innet/server 1.7.0 → 2.0.0-alpha.0
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 +3060 -387
- package/constants.d.ts +4 -1
- package/constants.es6.js +10 -2
- package/constants.js +11 -2
- package/declaration.d.ts +9 -0
- package/example/app/App/App.d.ts +1 -0
- package/example/app/App/index.d.ts +1 -0
- package/example/index.d.ts +1 -0
- package/example/requests/index.d.ts +1 -0
- package/example/requests/partners/EditPartner/EditPartner.d.ts +1 -0
- package/example/requests/partners/EditPartner/index.d.ts +1 -0
- package/example/requests/partners/GetPartner/GetPartner.d.ts +1 -0
- package/example/requests/partners/GetPartner/index.d.ts +1 -0
- package/example/requests/partners/GetPartners/GetPartners.d.ts +1 -0
- package/example/requests/partners/GetPartners/index.d.ts +1 -0
- package/example/requests/partners/index.d.ts +3 -0
- package/example/schemas/address/AddressSchema/AddressSchema.d.ts +1 -0
- package/example/schemas/address/AddressSchema/index.d.ts +1 -0
- package/example/schemas/address/index.d.ts +1 -0
- package/example/schemas/app/ListSchema/ListSchema.d.ts +1 -0
- package/example/schemas/app/ListSchema/index.d.ts +1 -0
- package/example/schemas/app/index.d.ts +1 -0
- package/example/schemas/index.d.ts +4 -0
- package/example/schemas/location/LocationSchema/LocationSchema.d.ts +1 -0
- package/example/schemas/location/LocationSchema/index.d.ts +1 -0
- package/example/schemas/location/index.d.ts +1 -0
- package/example/schemas/partner/EditPartnerSchema/EditPartnerSchema.d.ts +1 -0
- package/example/schemas/partner/EditPartnerSchema/index.d.ts +1 -0
- package/example/schemas/partner/PartnerSchema/PartnerSchema.d.ts +1 -0
- package/example/schemas/partner/PartnerSchema/index.d.ts +1 -0
- package/example/schemas/partner/index.d.ts +2 -0
- package/example/tags/Partner/Partner.d.ts +1 -0
- package/example/tags/Partner/index.d.ts +1 -0
- package/example/tags/index.d.ts +1 -0
- package/handler/handler.d.ts +96 -58
- package/handler/handler.es6.js +102 -63
- package/handler/handler.js +100 -65
- package/handler/index.d.ts +1 -1
- package/hooks/index.d.ts +25 -6
- package/hooks/index.es6.js +25 -6
- package/hooks/index.js +25 -18
- package/hooks/useAction/index.d.ts +1 -1
- package/hooks/useAction/useAction.d.ts +4 -4
- package/hooks/useAction/useAction.es6.js +9 -7
- package/hooks/useAction/useAction.js +9 -7
- package/hooks/useApi/index.d.ts +1 -0
- package/hooks/useApi/index.es6.js +1 -0
- package/hooks/useApi/index.js +10 -0
- package/hooks/useApi/useApi.d.ts +13 -0
- package/hooks/useApi/useApi.es6.js +12 -0
- package/hooks/useApi/useApi.js +17 -0
- package/hooks/useBlock/index.d.ts +1 -0
- package/hooks/useBlock/index.es6.js +1 -0
- package/hooks/{useFiles → useBlock}/index.js +2 -2
- package/hooks/useBlock/useBlock.d.ts +2 -0
- package/hooks/useBlock/useBlock.es6.js +14 -0
- package/hooks/useBlock/useBlock.js +18 -0
- package/hooks/useBody/index.d.ts +1 -1
- package/hooks/useBody/useBody.d.ts +1 -1
- package/hooks/useBody/useBody.es6.js +3 -2
- package/hooks/useBody/useBody.js +3 -2
- package/hooks/useBodyFile/index.d.ts +1 -0
- package/hooks/useBodyFile/index.es6.js +1 -0
- package/hooks/useBodyFile/index.js +10 -0
- package/hooks/useBodyFile/useBodyFile.d.ts +3 -0
- package/hooks/useBodyFile/useBodyFile.es6.js +14 -0
- package/hooks/useBodyFile/useBodyFile.js +19 -0
- package/hooks/useComponentName/index.d.ts +1 -0
- package/hooks/useComponentName/index.es6.js +1 -0
- package/hooks/useComponentName/index.js +9 -0
- package/hooks/useComponentName/useComponentName.d.ts +1 -0
- package/hooks/useComponentName/useComponentName.es6.js +8 -0
- package/hooks/useComponentName/useComponentName.js +12 -0
- package/hooks/useCookies/index.d.ts +1 -1
- package/hooks/useCookies/useCookies.d.ts +1 -2
- package/hooks/useCookies/useCookies.es6.js +3 -2
- package/hooks/useCookies/useCookies.js +3 -2
- package/hooks/useEndpoint/index.d.ts +1 -0
- package/hooks/useEndpoint/index.es6.js +1 -0
- package/hooks/useEndpoint/index.js +10 -0
- package/hooks/useEndpoint/useEndpoint.d.ts +10 -0
- package/hooks/useEndpoint/useEndpoint.es6.js +12 -0
- package/hooks/useEndpoint/useEndpoint.js +17 -0
- package/hooks/useHeaders/index.d.ts +1 -0
- package/hooks/useHeaders/index.es6.js +1 -0
- package/hooks/useHeaders/index.js +9 -0
- package/hooks/useHeaders/useHeaders.d.ts +3 -0
- package/hooks/useHeaders/useHeaders.es6.js +8 -0
- package/hooks/useHeaders/useHeaders.js +12 -0
- package/hooks/useHost/index.d.ts +1 -0
- package/hooks/useHost/index.es6.js +1 -0
- package/hooks/useHost/index.js +10 -0
- package/hooks/useHost/useHost.d.ts +7 -0
- package/hooks/useHost/useHost.es6.js +12 -0
- package/hooks/useHost/useHost.js +17 -0
- package/hooks/useNewSchema/index.d.ts +1 -0
- package/hooks/useNewSchema/index.es6.js +1 -0
- package/hooks/useNewSchema/index.js +9 -0
- package/hooks/useNewSchema/useNewSchema.d.ts +2 -0
- package/hooks/useNewSchema/useNewSchema.es6.js +32 -0
- package/hooks/useNewSchema/useNewSchema.js +36 -0
- package/hooks/useObjectRule/index.d.ts +1 -0
- package/hooks/useObjectRule/index.es6.js +1 -0
- package/hooks/useObjectRule/index.js +10 -0
- package/hooks/useObjectRule/useObjectRule.d.ts +4 -0
- package/hooks/useObjectRule/useObjectRule.es6.js +14 -0
- package/hooks/useObjectRule/useObjectRule.js +19 -0
- package/hooks/useOneElementError/index.d.ts +1 -0
- package/hooks/useOneElementError/index.es6.js +1 -0
- package/hooks/useOneElementError/index.js +9 -0
- package/hooks/useOneElementError/useOneElementError.d.ts +1 -0
- package/hooks/useOneElementError/useOneElementError.es6.js +8 -0
- package/hooks/useOneElementError/useOneElementError.js +12 -0
- package/hooks/useParam/index.d.ts +1 -0
- package/hooks/useParam/index.es6.js +1 -0
- package/hooks/useParam/index.js +10 -0
- package/hooks/useParam/useParam.d.ts +7 -0
- package/hooks/useParam/useParam.es6.js +12 -0
- package/hooks/useParam/useParam.js +17 -0
- package/hooks/useParams/index.d.ts +1 -0
- package/hooks/useParams/index.es6.js +1 -0
- package/hooks/useParams/index.js +10 -0
- package/hooks/useParams/useParams.d.ts +3 -0
- package/hooks/useParams/useParams.es6.js +8 -0
- package/hooks/useParams/useParams.js +13 -0
- package/hooks/useParentRule/index.d.ts +1 -0
- package/hooks/useParentRule/index.es6.js +1 -0
- package/hooks/useParentRule/index.js +10 -0
- package/hooks/useParentRule/useParentRule.d.ts +4 -0
- package/hooks/useParentRule/useParentRule.es6.js +10 -0
- package/hooks/useParentRule/useParentRule.js +15 -0
- package/hooks/usePath/index.d.ts +1 -0
- package/hooks/usePath/index.es6.js +1 -0
- package/hooks/usePath/index.js +9 -0
- package/hooks/usePath/usePath.d.ts +1 -0
- package/hooks/usePath/usePath.es6.js +8 -0
- package/hooks/{useFiles/useFiles.js → usePath/usePath.js} +4 -3
- package/hooks/useRequest/index.d.ts +1 -0
- package/hooks/useRequest/index.es6.js +1 -0
- package/hooks/useRequest/index.js +10 -0
- package/hooks/useRequest/useRequest.d.ts +5 -0
- package/hooks/useRequest/useRequest.es6.js +8 -0
- package/hooks/useRequest/useRequest.js +13 -0
- package/hooks/useResponse/index.d.ts +1 -0
- package/hooks/useResponse/index.es6.js +1 -0
- package/hooks/useResponse/index.js +10 -0
- package/hooks/useResponse/useResponse.d.ts +5 -0
- package/hooks/useResponse/useResponse.es6.js +8 -0
- package/hooks/useResponse/useResponse.js +13 -0
- package/hooks/useRule/index.d.ts +1 -0
- package/hooks/useRule/index.es6.js +1 -0
- package/hooks/useRule/index.js +11 -0
- package/hooks/useRule/useRule.d.ts +6 -0
- package/hooks/useRule/useRule.es6.js +17 -0
- package/hooks/useRule/useRule.js +23 -0
- package/hooks/useSchemaContext/index.d.ts +1 -0
- package/hooks/useSchemaContext/index.es6.js +1 -0
- package/hooks/useSchemaContext/index.js +10 -0
- package/hooks/useSchemaContext/useSchemaContext.d.ts +5 -0
- package/hooks/useSchemaContext/useSchemaContext.es6.js +8 -0
- package/hooks/useSchemaContext/useSchemaContext.js +13 -0
- package/hooks/useSchemaType/index.d.ts +1 -0
- package/hooks/useSchemaType/index.es6.js +1 -0
- package/hooks/useSchemaType/index.js +9 -0
- package/hooks/useSchemaType/useSchemaType.d.ts +4 -0
- package/hooks/useSchemaType/useSchemaType.es6.js +32 -0
- package/hooks/useSchemaType/useSchemaType.js +36 -0
- package/hooks/useSearch/index.d.ts +1 -1
- package/hooks/useSearch/useSearch.d.ts +1 -1
- package/hooks/useSearch/useSearch.es6.js +9 -2
- package/hooks/useSearch/useSearch.js +9 -2
- package/hooks/useServer/index.d.ts +1 -1
- package/hooks/useServer/useServer.d.ts +11 -7
- package/hooks/useServer/useServer.es6.js +7 -7
- package/hooks/useServer/useServer.js +7 -7
- package/hooks/useTag/index.d.ts +1 -0
- package/hooks/useTag/index.es6.js +1 -0
- package/hooks/useTag/index.js +10 -0
- package/hooks/useTag/useTag.d.ts +3 -0
- package/hooks/useTag/useTag.es6.js +8 -0
- package/hooks/useTag/useTag.js +13 -0
- package/hooks/useThrow/index.d.ts +1 -0
- package/hooks/useThrow/index.es6.js +1 -0
- package/hooks/useThrow/index.js +9 -0
- package/hooks/useThrow/useThrow.d.ts +1 -0
- package/hooks/useThrow/useThrow.es6.js +9 -0
- package/hooks/useThrow/useThrow.js +13 -0
- package/index.d.ts +6 -5
- package/index.es6.js +104 -21
- package/index.js +213 -44
- package/openApi.test.d.ts +1 -0
- package/package.json +27 -12
- package/{experimental/serverFn → plugins/handler}/index.d.ts +1 -1
- package/plugins/handler/index.es6.js +1 -0
- package/plugins/handler/index.js +4 -0
- package/plugins/handler/serverFn/index.d.ts +1 -0
- package/plugins/handler/serverFn/serverFn.d.ts +2 -0
- package/plugins/handler/serverFn/serverFn.es6.js +14 -0
- package/{experimental → plugins/handler}/serverFn/serverFn.js +9 -7
- package/plugins/index.d.ts +5 -15
- package/plugins/index.es6.js +5 -15
- package/plugins/index.js +5 -42
- package/plugins/main/api/api.d.ts +22 -0
- package/plugins/main/api/api.es6.js +180 -0
- package/plugins/main/api/api.js +188 -0
- package/plugins/main/api/index.d.ts +1 -0
- package/plugins/main/api/index.es6.js +1 -0
- package/plugins/main/api/index.js +9 -0
- package/plugins/main/body/body.d.ts +4 -0
- package/plugins/main/body/body.es6.js +55 -0
- package/plugins/main/body/body.js +63 -0
- package/plugins/main/body/index.d.ts +1 -0
- package/plugins/main/body/index.es6.js +1 -0
- package/plugins/main/body/index.js +9 -0
- package/plugins/main/contact/contact.d.ts +10 -0
- package/plugins/main/contact/contact.es6.js +16 -0
- package/plugins/main/contact/contact.js +20 -0
- package/plugins/main/contact/index.d.ts +1 -0
- package/plugins/main/contact/index.es6.js +1 -0
- package/plugins/main/contact/index.js +9 -0
- package/plugins/main/endpoint/endpoint.d.ts +37 -0
- package/plugins/main/endpoint/endpoint.es6.js +54 -0
- package/plugins/main/endpoint/endpoint.js +62 -0
- package/plugins/main/endpoint/index.d.ts +1 -0
- package/plugins/main/endpoint/index.es6.js +1 -0
- package/plugins/main/endpoint/index.js +9 -0
- package/plugins/main/fallback/fallback.d.ts +4 -0
- package/plugins/main/fallback/fallback.es6.js +19 -0
- package/plugins/main/fallback/fallback.js +23 -0
- package/plugins/main/fallback/index.d.ts +1 -0
- package/plugins/main/fallback/index.es6.js +1 -0
- package/plugins/main/fallback/index.js +9 -0
- package/plugins/main/host/host.d.ts +16 -0
- package/plugins/main/host/host.es6.js +26 -0
- package/plugins/main/host/host.js +34 -0
- package/plugins/main/host/index.d.ts +1 -0
- package/plugins/main/host/index.es6.js +1 -0
- package/plugins/main/host/index.js +9 -0
- package/plugins/main/index.d.ts +13 -0
- package/plugins/main/index.es6.js +13 -0
- package/plugins/main/index.js +16 -0
- package/plugins/main/license/index.d.ts +1 -0
- package/plugins/main/license/index.es6.js +1 -0
- package/plugins/main/license/index.js +9 -0
- package/plugins/main/license/license.d.ts +21 -0
- package/plugins/main/license/license.es6.js +15 -0
- package/plugins/main/license/license.js +19 -0
- package/plugins/main/param/index.d.ts +1 -0
- package/plugins/main/param/index.es6.js +1 -0
- package/plugins/main/param/index.js +9 -0
- package/plugins/main/param/param.d.ts +35 -0
- package/plugins/main/param/param.es6.js +63 -0
- package/plugins/main/param/param.js +71 -0
- package/plugins/main/request/index.d.ts +1 -0
- package/plugins/main/request/index.es6.js +1 -0
- package/plugins/main/request/index.js +9 -0
- package/plugins/main/request/request.d.ts +4 -0
- package/plugins/main/request/request.es6.js +21 -0
- package/plugins/main/request/request.js +25 -0
- package/plugins/main/response/index.d.ts +1 -0
- package/plugins/main/response/index.es6.js +1 -0
- package/plugins/main/response/index.js +9 -0
- package/plugins/main/response/response.d.ts +16 -0
- package/plugins/main/response/response.es6.js +44 -0
- package/plugins/main/response/response.js +52 -0
- package/plugins/{server → main/server}/index.d.ts +1 -1
- package/plugins/main/server/server.d.ts +13 -0
- package/plugins/main/server/server.es6.js +44 -0
- package/plugins/main/server/server.js +55 -0
- package/plugins/main/tag/index.d.ts +1 -0
- package/plugins/main/tag/index.es6.js +1 -0
- package/plugins/main/tag/index.js +9 -0
- package/plugins/main/tag/tag.d.ts +11 -0
- package/plugins/main/tag/tag.es6.js +29 -0
- package/plugins/main/tag/tag.js +37 -0
- package/plugins/main/variable/index.d.ts +1 -0
- package/plugins/main/variable/index.es6.js +1 -0
- package/plugins/main/variable/index.js +9 -0
- package/plugins/main/variable/variable.d.ts +24 -0
- package/plugins/main/variable/variable.es6.js +16 -0
- package/plugins/main/variable/variable.js +20 -0
- package/plugins/request/cms/cms.d.ts +5 -0
- package/plugins/request/cms/cms.es6.js +24 -0
- package/plugins/request/cms/cms.js +33 -0
- package/plugins/{cms → request/cms}/index.d.ts +1 -1
- package/plugins/request/cookie/cookie.d.ts +7 -0
- package/plugins/request/cookie/cookie.es6.js +28 -0
- package/plugins/request/cookie/cookie.js +36 -0
- package/plugins/{cookie → request/cookie}/index.d.ts +1 -1
- package/plugins/{error → request/error}/error.d.ts +60 -61
- package/plugins/{error → request/error}/error.es6.js +70 -70
- package/plugins/{error → request/error}/error.js +70 -75
- package/plugins/{error → request/error}/index.d.ts +1 -1
- package/plugins/request/file/file.d.ts +4 -0
- package/plugins/request/file/file.es6.js +38 -0
- package/plugins/request/file/file.js +48 -0
- package/plugins/{file → request/file}/index.d.ts +1 -1
- package/plugins/request/header/header.d.ts +6 -0
- package/plugins/request/header/header.es6.js +15 -0
- package/plugins/request/header/header.js +19 -0
- package/plugins/{header → request/header}/index.d.ts +1 -1
- package/plugins/request/index.d.ts +8 -0
- package/plugins/request/index.es6.js +8 -0
- package/plugins/request/index.js +11 -0
- package/plugins/{proxy → request/proxy}/index.d.ts +1 -1
- package/plugins/request/proxy/proxy.d.ts +6 -0
- package/plugins/request/proxy/proxy.es6.js +20 -0
- package/plugins/request/proxy/proxy.js +28 -0
- package/plugins/{redirect → request/redirect}/index.d.ts +1 -1
- package/plugins/{redirect → request/redirect}/redirect.d.ts +17 -19
- package/plugins/request/redirect/redirect.es6.js +41 -0
- package/plugins/request/redirect/redirect.js +46 -0
- package/plugins/{success → request/success}/index.d.ts +1 -1
- package/plugins/{success → request/success}/success.d.ts +17 -19
- package/plugins/request/success/success.es6.js +33 -0
- package/plugins/request/success/success.js +38 -0
- package/plugins/schema/array/array.d.ts +5 -0
- package/plugins/schema/array/array.es6.js +58 -0
- package/plugins/schema/array/array.js +66 -0
- package/plugins/schema/array/index.d.ts +1 -0
- package/plugins/schema/array/index.es6.js +1 -0
- package/plugins/schema/array/index.js +9 -0
- package/plugins/schema/binary/binary.d.ts +9 -0
- package/plugins/schema/binary/binary.es6.js +39 -0
- package/plugins/schema/binary/binary.js +43 -0
- package/plugins/schema/binary/index.d.ts +1 -0
- package/plugins/schema/binary/index.es6.js +1 -0
- package/plugins/{action → schema/binary}/index.js +2 -2
- package/plugins/schema/boolean/boolean.d.ts +5 -0
- package/plugins/schema/boolean/boolean.es6.js +32 -0
- package/plugins/schema/boolean/boolean.js +36 -0
- package/plugins/schema/boolean/index.d.ts +1 -0
- package/plugins/schema/boolean/index.es6.js +1 -0
- package/plugins/schema/boolean/index.js +9 -0
- package/plugins/schema/date/date.d.ts +8 -0
- package/plugins/schema/date/date.es6.js +64 -0
- package/plugins/schema/date/date.js +68 -0
- package/plugins/schema/date/index.d.ts +1 -0
- package/plugins/schema/date/index.es6.js +1 -0
- package/plugins/schema/date/index.js +9 -0
- package/plugins/schema/field/field.d.ts +6 -0
- package/plugins/schema/field/field.es6.js +46 -0
- package/plugins/schema/field/field.js +54 -0
- package/plugins/schema/field/index.d.ts +1 -0
- package/plugins/schema/field/index.es6.js +1 -0
- package/plugins/schema/field/index.js +9 -0
- package/plugins/schema/index.d.ts +12 -0
- package/plugins/schema/index.es6.js +12 -0
- package/plugins/schema/index.js +15 -0
- package/plugins/schema/integer/index.d.ts +1 -0
- package/plugins/schema/integer/index.es6.js +1 -0
- package/plugins/schema/integer/index.js +9 -0
- package/plugins/schema/integer/integer.d.ts +8 -0
- package/plugins/schema/integer/integer.es6.js +46 -0
- package/plugins/schema/integer/integer.js +50 -0
- package/plugins/schema/null/index.d.ts +1 -0
- package/plugins/schema/null/index.es6.js +1 -0
- package/plugins/schema/null/index.js +9 -0
- package/plugins/schema/null/null.d.ts +5 -0
- package/plugins/schema/null/null.es6.js +15 -0
- package/plugins/schema/null/null.js +19 -0
- package/plugins/schema/number/index.d.ts +1 -0
- package/plugins/schema/number/index.es6.js +1 -0
- package/plugins/schema/number/index.js +9 -0
- package/plugins/schema/number/number.d.ts +9 -0
- package/plugins/schema/number/number.es6.js +46 -0
- package/plugins/schema/number/number.js +50 -0
- package/plugins/schema/object/index.d.ts +1 -0
- package/plugins/schema/object/index.es6.js +1 -0
- package/plugins/schema/object/index.js +9 -0
- package/plugins/schema/object/object.d.ts +5 -0
- package/plugins/schema/object/object.es6.js +54 -0
- package/plugins/schema/object/object.js +62 -0
- package/plugins/schema/string/index.d.ts +1 -0
- package/plugins/schema/string/index.es6.js +1 -0
- package/plugins/schema/string/index.js +9 -0
- package/plugins/schema/string/string.d.ts +9 -0
- package/plugins/schema/string/string.es6.js +51 -0
- package/plugins/schema/string/string.js +55 -0
- package/plugins/schema/tuple/index.d.ts +1 -0
- package/plugins/schema/tuple/index.es6.js +1 -0
- package/plugins/schema/tuple/index.js +9 -0
- package/plugins/schema/tuple/tuple.d.ts +5 -0
- package/plugins/schema/tuple/tuple.es6.js +54 -0
- package/plugins/schema/tuple/tuple.js +62 -0
- package/plugins/schema/uuid/index.d.ts +1 -0
- package/plugins/schema/uuid/index.es6.js +1 -0
- package/plugins/schema/uuid/index.js +9 -0
- package/plugins/schema/uuid/uuid.d.ts +6 -0
- package/plugins/schema/uuid/uuid.es6.js +39 -0
- package/plugins/schema/uuid/uuid.js +43 -0
- package/plugins/utils/dev/dev.d.ts +4 -0
- package/plugins/utils/dev/dev.es6.js +10 -0
- package/plugins/utils/dev/dev.js +18 -0
- package/plugins/utils/dev/index.d.ts +1 -0
- package/plugins/utils/dev/index.es6.js +1 -0
- package/plugins/utils/dev/index.js +9 -0
- package/plugins/utils/dts/dts.d.ts +6 -0
- package/plugins/utils/dts/dts.es6.js +35 -0
- package/plugins/utils/dts/dts.js +44 -0
- package/plugins/utils/dts/index.d.ts +1 -0
- package/plugins/utils/dts/index.es6.js +1 -0
- package/plugins/utils/dts/index.js +9 -0
- package/plugins/utils/index.d.ts +4 -0
- package/plugins/utils/index.es6.js +4 -0
- package/plugins/utils/index.js +7 -0
- package/plugins/utils/prod/index.d.ts +1 -0
- package/plugins/utils/prod/index.es6.js +1 -0
- package/plugins/utils/prod/index.js +9 -0
- package/plugins/utils/prod/prod.d.ts +4 -0
- package/plugins/utils/prod/prod.es6.js +10 -0
- package/plugins/utils/prod/prod.js +18 -0
- package/plugins/utils/swagger/index.d.ts +1 -0
- package/plugins/utils/swagger/index.es6.js +1 -0
- package/plugins/utils/swagger/index.js +9 -0
- package/plugins/utils/swagger/swagger.d.ts +5 -0
- package/plugins/utils/swagger/swagger.es6.js +28 -0
- package/plugins/utils/swagger/swagger.html.es6.js +3 -0
- package/plugins/utils/swagger/swagger.html.js +7 -0
- package/plugins/utils/swagger/swagger.js +32 -0
- package/types.d.ts +76 -0
- package/types.es6.js +1 -0
- package/types.js +2 -0
- package/utils/FileData/Bin.d.ts +47 -0
- package/utils/FileData/Bin.es6.js +19 -0
- package/utils/FileData/Bin.js +23 -0
- package/utils/FileData/index.d.ts +1 -0
- package/utils/FileData/index.es6.js +1 -0
- package/utils/FileData/index.js +9 -0
- package/utils/JSONString/JSONString.d.ts +1 -0
- package/utils/JSONString/JSONString.es6.js +10 -0
- package/utils/JSONString/JSONString.js +14 -0
- package/utils/JSONString/index.d.ts +1 -0
- package/utils/JSONString/index.es6.js +1 -0
- package/utils/JSONString/index.js +9 -0
- package/utils/action/Action.d.ts +29 -0
- package/utils/action/Action.es6.js +125 -0
- package/utils/action/Action.js +134 -0
- package/utils/action/index.d.ts +1 -1
- package/utils/action/index.es6.js +1 -1
- package/utils/action/index.js +1 -3
- package/utils/dateFormat/dateFormat.d.ts +2 -0
- package/utils/dateFormat/dateFormat.es6.js +11 -0
- package/utils/dateFormat/dateFormat.js +15 -0
- package/utils/dateFormat/index.d.ts +1 -0
- package/utils/dateFormat/index.es6.js +1 -0
- package/utils/dateFormat/index.js +9 -0
- package/utils/decorators/index.d.ts +1 -0
- package/utils/decorators/index.es6.js +1 -0
- package/utils/decorators/index.js +4 -0
- package/utils/decorators/once/index.d.ts +1 -0
- package/utils/decorators/once/index.es6.js +1 -0
- package/utils/decorators/once/index.js +9 -0
- package/utils/decorators/once/once.d.ts +4 -0
- package/utils/decorators/once/once.es6.js +28 -0
- package/utils/decorators/once/once.js +32 -0
- package/utils/decorators/once/once.test.d.ts +1 -0
- package/utils/getEndpoint/getEndpoint.d.ts +2 -0
- package/utils/getEndpoint/getEndpoint.es6.js +31 -0
- package/utils/getEndpoint/getEndpoint.js +35 -0
- package/utils/getEndpoint/index.d.ts +1 -0
- package/utils/getEndpoint/index.es6.js +1 -0
- package/utils/getEndpoint/index.js +9 -0
- package/utils/getOrAdd/getOrAdd.d.ts +1 -0
- package/utils/getOrAdd/getOrAdd.es6.js +14 -0
- package/utils/getOrAdd/getOrAdd.js +18 -0
- package/utils/getOrAdd/index.d.ts +1 -0
- package/utils/getOrAdd/index.es6.js +1 -0
- package/utils/getOrAdd/index.js +9 -0
- package/utils/httpOnStart/httpOnStart.d.ts +2 -0
- package/utils/httpOnStart/httpOnStart.es6.js +5 -0
- package/utils/httpOnStart/httpOnStart.js +9 -0
- package/utils/httpOnStart/index.d.ts +1 -0
- package/utils/httpOnStart/index.es6.js +1 -0
- package/utils/httpOnStart/index.js +9 -0
- package/utils/index.d.ts +12 -3
- package/utils/index.es6.js +12 -3
- package/utils/index.js +12 -13
- package/{plugins → utils}/parseBody/index.d.ts +1 -1
- package/utils/parseBody/parseBody.d.ts +3 -0
- package/utils/parseBody/parseBody.es6.js +23 -0
- package/utils/parseBody/parseBody.js +27 -0
- package/utils/parseFormBody/index.d.ts +1 -0
- package/utils/parseFormBody/index.es6.js +1 -0
- package/utils/parseFormBody/index.js +9 -0
- package/utils/parseFormBody/parseFormBody.d.ts +3 -0
- package/utils/parseFormBody/parseFormBody.es6.js +56 -0
- package/utils/parseFormBody/parseFormBody.js +60 -0
- package/utils/parseSearch/index.d.ts +1 -1
- package/utils/parseSearch/index.es6.js +1 -1
- package/utils/parseSearch/index.js +1 -0
- package/utils/parseSearch/parseSearch.d.ts +3 -2
- package/utils/parseSearch/parseSearch.es6.js +6 -3
- package/utils/parseSearch/parseSearch.js +6 -3
- package/utils/parseSearch/parseSearch.test.d.ts +1 -0
- package/utils/rules/any/any.d.ts +1 -0
- package/utils/rules/any/any.es6.js +5 -0
- package/utils/rules/any/any.js +9 -0
- package/utils/rules/any/index.d.ts +1 -0
- package/utils/rules/any/index.es6.js +1 -0
- package/utils/rules/any/index.js +9 -0
- package/utils/rules/arrayOf/arrayOf.d.ts +2 -0
- package/utils/rules/arrayOf/arrayOf.es6.js +15 -0
- package/utils/rules/arrayOf/arrayOf.js +19 -0
- package/utils/rules/arrayOf/index.d.ts +1 -0
- package/utils/rules/arrayOf/index.es6.js +1 -0
- package/utils/rules/arrayOf/index.js +9 -0
- package/utils/rules/bin/bin.d.ts +2 -0
- package/utils/rules/bin/bin.es6.js +12 -0
- package/utils/rules/bin/bin.js +16 -0
- package/utils/rules/bin/index.d.ts +1 -0
- package/utils/rules/bin/index.es6.js +1 -0
- package/utils/rules/bin/index.js +9 -0
- package/utils/rules/binaryAccept/binaryAccept.d.ts +2 -0
- package/utils/rules/binaryAccept/binaryAccept.es6.js +32 -0
- package/utils/rules/binaryAccept/binaryAccept.js +36 -0
- package/utils/rules/binaryAccept/index.d.ts +1 -0
- package/utils/rules/binaryAccept/index.es6.js +1 -0
- package/utils/rules/binaryAccept/index.js +9 -0
- package/utils/rules/constants.d.ts +1 -0
- package/utils/rules/constants.es6.js +28 -0
- package/utils/rules/constants.js +32 -0
- package/utils/rules/dateTo/dateTo.d.ts +2 -0
- package/utils/rules/dateTo/dateTo.es6.js +11 -0
- package/utils/rules/dateTo/dateTo.js +15 -0
- package/utils/rules/dateTo/index.d.ts +1 -0
- package/utils/rules/dateTo/index.es6.js +1 -0
- package/utils/rules/dateTo/index.js +9 -0
- package/utils/rules/defaultTo/defaultTo.d.ts +1 -0
- package/utils/rules/defaultTo/defaultTo.es6.js +9 -0
- package/utils/rules/defaultTo/defaultTo.js +13 -0
- package/utils/rules/defaultTo/index.d.ts +1 -0
- package/utils/rules/defaultTo/index.es6.js +1 -0
- package/utils/rules/defaultTo/index.js +9 -0
- package/utils/rules/helpers.d.ts +8 -0
- package/utils/rules/helpers.es6.js +11 -0
- package/utils/rules/helpers.js +16 -0
- package/utils/rules/index.d.ts +29 -0
- package/utils/rules/index.es6.js +29 -0
- package/utils/rules/index.js +39 -0
- package/utils/rules/int/index.d.ts +1 -0
- package/utils/rules/int/index.es6.js +1 -0
- package/utils/rules/int/index.js +9 -0
- package/utils/rules/int/int.d.ts +2 -0
- package/utils/rules/int/int.es6.js +36 -0
- package/utils/rules/int/int.js +40 -0
- package/utils/rules/max/index.d.ts +1 -0
- package/utils/rules/max/index.es6.js +1 -0
- package/utils/rules/max/index.js +9 -0
- package/utils/rules/max/max.d.ts +1 -0
- package/utils/rules/max/max.es6.js +16 -0
- package/utils/rules/max/max.js +20 -0
- package/utils/rules/maxBin/index.d.ts +1 -0
- package/utils/rules/maxBin/index.es6.js +1 -0
- package/utils/rules/maxBin/index.js +9 -0
- package/utils/rules/maxBin/maxBin.d.ts +2 -0
- package/utils/rules/maxBin/maxBin.es6.js +13 -0
- package/utils/rules/maxBin/maxBin.js +17 -0
- package/utils/rules/maxDate/index.d.ts +1 -0
- package/utils/rules/maxDate/index.es6.js +1 -0
- package/utils/rules/maxDate/index.js +9 -0
- package/utils/rules/maxDate/maxDate.d.ts +1 -0
- package/utils/rules/maxDate/maxDate.es6.js +15 -0
- package/utils/rules/maxDate/maxDate.js +19 -0
- package/utils/rules/maxLength/index.d.ts +1 -0
- package/utils/rules/maxLength/index.es6.js +1 -0
- package/utils/rules/maxLength/index.js +9 -0
- package/utils/rules/maxLength/maxLength.d.ts +1 -0
- package/utils/rules/maxLength/maxLength.es6.js +16 -0
- package/utils/rules/maxLength/maxLength.js +20 -0
- package/utils/rules/min/index.d.ts +1 -0
- package/utils/rules/min/index.es6.js +1 -0
- package/utils/rules/min/index.js +9 -0
- package/utils/rules/min/min.d.ts +1 -0
- package/utils/rules/min/min.es6.js +16 -0
- package/utils/rules/min/min.js +20 -0
- package/utils/rules/minBin/index.d.ts +1 -0
- package/utils/rules/minBin/index.es6.js +1 -0
- package/utils/rules/minBin/index.js +9 -0
- package/utils/rules/minBin/minBin.d.ts +2 -0
- package/utils/rules/minBin/minBin.es6.js +13 -0
- package/utils/rules/minBin/minBin.js +17 -0
- package/utils/rules/minDate/index.d.ts +1 -0
- package/utils/rules/minDate/index.es6.js +1 -0
- package/utils/rules/minDate/index.js +9 -0
- package/utils/rules/minDate/minDate.d.ts +1 -0
- package/utils/rules/minDate/minDate.es6.js +15 -0
- package/utils/rules/minDate/minDate.js +19 -0
- package/utils/rules/minLength/index.d.ts +1 -0
- package/utils/rules/minLength/index.es6.js +1 -0
- package/utils/rules/minLength/index.js +9 -0
- package/utils/rules/minLength/minLength.d.ts +1 -0
- package/utils/rules/minLength/minLength.es6.js +16 -0
- package/utils/rules/minLength/minLength.js +20 -0
- package/utils/rules/nullable/index.d.ts +1 -0
- package/utils/rules/nullable/index.es6.js +1 -0
- package/utils/rules/nullable/index.js +9 -0
- package/utils/rules/nullable/nullable.d.ts +1 -0
- package/utils/rules/nullable/nullable.es6.js +10 -0
- package/utils/rules/nullable/nullable.js +14 -0
- package/utils/rules/num/index.d.ts +1 -0
- package/utils/rules/num/index.es6.js +1 -0
- package/utils/rules/num/index.js +9 -0
- package/utils/rules/num/num.d.ts +1 -0
- package/utils/rules/num/num.es6.js +11 -0
- package/utils/rules/num/num.js +15 -0
- package/utils/rules/objectOf/index.d.ts +1 -0
- package/utils/rules/objectOf/index.es6.js +1 -0
- package/utils/rules/objectOf/index.js +9 -0
- package/utils/rules/objectOf/objectOf.d.ts +3 -0
- package/utils/rules/objectOf/objectOf.es6.js +16 -0
- package/utils/rules/objectOf/objectOf.js +20 -0
- package/utils/rules/oneOf/index.d.ts +1 -0
- package/utils/rules/oneOf/index.es6.js +1 -0
- package/utils/rules/oneOf/index.js +9 -0
- package/utils/rules/oneOf/oneOf.d.ts +2 -0
- package/utils/rules/oneOf/oneOf.es6.js +18 -0
- package/utils/rules/oneOf/oneOf.js +22 -0
- package/utils/rules/optional/index.d.ts +1 -0
- package/utils/rules/optional/index.es6.js +1 -0
- package/utils/rules/optional/index.js +9 -0
- package/utils/rules/optional/optional.d.ts +2 -0
- package/utils/rules/optional/optional.es6.js +9 -0
- package/utils/rules/optional/optional.js +13 -0
- package/utils/rules/pattern/index.d.ts +1 -0
- package/utils/rules/pattern/index.es6.js +1 -0
- package/utils/rules/pattern/index.js +9 -0
- package/utils/rules/pattern/pattern.d.ts +1 -0
- package/utils/rules/pattern/pattern.es6.js +13 -0
- package/utils/rules/pattern/pattern.js +17 -0
- package/utils/rules/pipe/index.d.ts +1 -0
- package/utils/rules/pipe/index.es6.js +1 -0
- package/utils/rules/pipe/index.js +9 -0
- package/utils/rules/pipe/pipe.d.ts +2 -0
- package/utils/rules/pipe/pipe.es6.js +7 -0
- package/utils/rules/pipe/pipe.js +11 -0
- package/utils/rules/required/index.d.ts +1 -0
- package/utils/rules/required/index.es6.js +1 -0
- package/utils/rules/required/index.js +9 -0
- package/utils/rules/required/required.d.ts +2 -0
- package/utils/rules/required/required.es6.js +12 -0
- package/utils/rules/required/required.js +16 -0
- package/utils/rules/tupleOf/index.d.ts +1 -0
- package/utils/rules/tupleOf/index.es6.js +1 -0
- package/utils/rules/tupleOf/index.js +9 -0
- package/utils/rules/tupleOf/tupleOf.d.ts +2 -0
- package/utils/rules/tupleOf/tupleOf.es6.js +19 -0
- package/utils/rules/tupleOf/tupleOf.js +23 -0
- package/utils/rules/types.d.ts +4 -0
- package/utils/rules/types.es6.js +1 -0
- package/utils/rules/types.js +2 -0
- package/utils/rules/uuidTo/index.d.ts +1 -0
- package/utils/rules/uuidTo/index.es6.js +1 -0
- package/utils/rules/uuidTo/index.js +9 -0
- package/utils/rules/uuidTo/uuidTo.d.ts +1 -0
- package/utils/rules/uuidTo/uuidTo.es6.js +11 -0
- package/utils/rules/uuidTo/uuidTo.js +15 -0
- package/utils/rules/values/index.d.ts +1 -0
- package/utils/rules/values/index.es6.js +1 -0
- package/utils/rules/values/index.js +9 -0
- package/utils/rules/values/values.d.ts +1 -0
- package/utils/rules/values/values.es6.js +13 -0
- package/utils/rules/values/values.js +17 -0
- package/utils/stringifySearch/index.d.ts +1 -1
- package/utils/stringifySearch/stringifySearch.d.ts +2 -2
- package/utils/stringifySearch/stringifySearch.es6.js +2 -2
- package/utils/stringifySearch/stringifySearch.js +2 -3
- package/experimental/serverFn/serverFn.d.ts +0 -2
- package/experimental/serverFn/serverFn.es6.js +0 -12
- package/hooks/useFiles/index.d.ts +0 -1
- package/hooks/useFiles/index.es6.js +0 -1
- package/hooks/useFiles/useFiles.d.ts +0 -1
- package/hooks/useFiles/useFiles.es6.js +0 -7
- package/plugins/access/access.d.ts +0 -14
- package/plugins/access/access.es6.js +0 -24
- package/plugins/access/access.js +0 -34
- package/plugins/access/index.d.ts +0 -1
- package/plugins/access/index.es6.js +0 -1
- package/plugins/access/index.js +0 -10
- package/plugins/action/action.d.ts +0 -10
- package/plugins/action/action.es6.js +0 -38
- package/plugins/action/action.js +0 -60
- package/plugins/action/index.d.ts +0 -1
- package/plugins/action/index.es6.js +0 -1
- package/plugins/cms/cms.d.ts +0 -9
- package/plugins/cms/cms.es6.js +0 -25
- package/plugins/cms/cms.js +0 -34
- package/plugins/cookie/cookie.d.ts +0 -14
- package/plugins/cookie/cookie.es6.js +0 -21
- package/plugins/cookie/cookie.js +0 -29
- package/plugins/file/file.d.ts +0 -7
- package/plugins/file/file.es6.js +0 -39
- package/plugins/file/file.js +0 -50
- package/plugins/formatter/formatter.d.ts +0 -16
- package/plugins/formatter/formatter.es6.js +0 -30
- package/plugins/formatter/formatter.js +0 -51
- package/plugins/formatter/index.d.ts +0 -1
- package/plugins/formatter/index.es6.js +0 -1
- package/plugins/formatter/index.js +0 -9
- package/plugins/header/header.d.ts +0 -12
- package/plugins/header/header.es6.js +0 -14
- package/plugins/header/header.js +0 -23
- package/plugins/parseBody/parseBody.d.ts +0 -7
- package/plugins/parseBody/parseBody.es6.js +0 -9
- package/plugins/parseBody/parseBody.js +0 -18
- package/plugins/proxy/proxy.d.ts +0 -10
- package/plugins/proxy/proxy.es6.js +0 -18
- package/plugins/proxy/proxy.js +0 -27
- package/plugins/redirect/redirect.es6.js +0 -34
- package/plugins/redirect/redirect.js +0 -40
- package/plugins/router/index.d.ts +0 -1
- package/plugins/router/index.es6.js +0 -1
- package/plugins/router/index.js +0 -12
- package/plugins/router/router.d.ts +0 -20
- package/plugins/router/router.es6.js +0 -51
- package/plugins/router/router.js +0 -63
- package/plugins/server/server.d.ts +0 -22
- package/plugins/server/server.es6.js +0 -43
- package/plugins/server/server.js +0 -55
- package/plugins/success/success.es6.js +0 -34
- package/plugins/success/success.js +0 -44
- package/plugins/validation/index.d.ts +0 -1
- package/plugins/validation/index.es6.js +0 -1
- package/plugins/validation/index.js +0 -10
- package/plugins/validation/validation.d.ts +0 -16
- package/plugins/validation/validation.es6.js +0 -31
- package/plugins/validation/validation.js +0 -41
- package/utils/action/Action/Action.d.ts +0 -48
- package/utils/action/Action/Action.es6.js +0 -134
- package/utils/action/Action/Action.js +0 -165
- package/utils/action/Action/index.d.ts +0 -1
- package/utils/action/Action/index.es6.js +0 -1
- package/utils/action/Action/index.js +0 -12
- /package/{experimental → plugins/handler}/serverFn/index.es6.js +0 -0
- /package/{experimental → plugins/handler}/serverFn/index.js +0 -0
- /package/plugins/{server → main/server}/index.es6.js +0 -0
- /package/plugins/{server → main/server}/index.js +0 -0
- /package/plugins/{cms → request/cms}/index.es6.js +0 -0
- /package/plugins/{cms → request/cms}/index.js +0 -0
- /package/plugins/{cookie → request/cookie}/index.es6.js +0 -0
- /package/plugins/{cookie → request/cookie}/index.js +0 -0
- /package/plugins/{error → request/error}/index.es6.js +0 -0
- /package/plugins/{error → request/error}/index.js +0 -0
- /package/plugins/{file → request/file}/index.es6.js +0 -0
- /package/plugins/{file → request/file}/index.js +0 -0
- /package/plugins/{header → request/header}/index.es6.js +0 -0
- /package/plugins/{header → request/header}/index.js +0 -0
- /package/plugins/{proxy → request/proxy}/index.es6.js +0 -0
- /package/plugins/{proxy → request/proxy}/index.js +0 -0
- /package/plugins/{redirect → request/redirect}/index.es6.js +0 -0
- /package/plugins/{redirect → request/redirect}/index.js +0 -0
- /package/plugins/{success → request/success}/index.es6.js +0 -0
- /package/plugins/{success → request/success}/index.js +0 -0
- /package/{plugins → utils}/parseBody/index.es6.js +0 -0
- /package/{plugins → utils}/parseBody/index.js +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import innet from 'innet';
|
|
2
|
-
import { actionContext } from '../../hooks/useAction/useAction.es6.js';
|
|
3
|
-
import '../../hooks/useServer/useServer.es6.js';
|
|
4
|
-
|
|
5
|
-
function header({ props: { name, value }, children }, handler) {
|
|
6
|
-
const action = actionContext.get(handler);
|
|
7
|
-
if (!action) {
|
|
8
|
-
throw Error('Use <header> inside <action>');
|
|
9
|
-
}
|
|
10
|
-
action.res.setHeader(name, value);
|
|
11
|
-
return innet(children, handler);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { header };
|
package/plugins/header/header.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var innet = require('innet');
|
|
6
|
-
var useAction = require('../../hooks/useAction/useAction.js');
|
|
7
|
-
require('../../hooks/useServer/useServer.js');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
-
|
|
11
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
12
|
-
|
|
13
|
-
function header(_a, handler) {
|
|
14
|
-
var _b = _a.props, name = _b.name, value = _b.value, children = _a.children;
|
|
15
|
-
var action = useAction.actionContext.get(handler);
|
|
16
|
-
if (!action) {
|
|
17
|
-
throw Error('Use <header> inside <action>');
|
|
18
|
-
}
|
|
19
|
-
action.res.setHeader(name, value);
|
|
20
|
-
return innet__default["default"](children, handler);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
exports.header = header;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import innet from 'innet';
|
|
2
|
-
import { actionContext } from '../../hooks/useAction/useAction.es6.js';
|
|
3
|
-
import '../../hooks/useServer/useServer.es6.js';
|
|
4
|
-
|
|
5
|
-
function parseBody({ props, children }, handler) {
|
|
6
|
-
return actionContext.get(handler).parseBody().then(() => innet(children, handler));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export { parseBody };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var innet = require('innet');
|
|
6
|
-
var useAction = require('../../hooks/useAction/useAction.js');
|
|
7
|
-
require('../../hooks/useServer/useServer.js');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
-
|
|
11
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
12
|
-
|
|
13
|
-
function parseBody(_a, handler) {
|
|
14
|
-
_a.props; var children = _a.children;
|
|
15
|
-
return useAction.actionContext.get(handler).parseBody().then(function () { return innet__default["default"](children, handler); });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
exports.parseBody = parseBody;
|
package/plugins/proxy/proxy.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import httpProxy from 'http-proxy';
|
|
2
|
-
import { CONTINUE } from '../../constants.es6.js';
|
|
3
|
-
import { actionContext } from '../../hooks/useAction/useAction.es6.js';
|
|
4
|
-
import '../../hooks/useServer/useServer.es6.js';
|
|
5
|
-
|
|
6
|
-
const proxyServer = httpProxy.createProxyServer({});
|
|
7
|
-
function proxy({ props: { to, secure = false } }, handler) {
|
|
8
|
-
const action = actionContext.get(handler);
|
|
9
|
-
if (!action) {
|
|
10
|
-
throw Error('Use <proxy> inside <action>');
|
|
11
|
-
}
|
|
12
|
-
const { req, res } = action;
|
|
13
|
-
delete req.headers.host;
|
|
14
|
-
proxyServer.web(req, res, { target: to, secure });
|
|
15
|
-
return CONTINUE;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { proxy };
|
package/plugins/proxy/proxy.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var httpProxy = require('http-proxy');
|
|
6
|
-
var constants = require('../../constants.js');
|
|
7
|
-
var useAction = require('../../hooks/useAction/useAction.js');
|
|
8
|
-
require('../../hooks/useServer/useServer.js');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
-
|
|
12
|
-
var httpProxy__default = /*#__PURE__*/_interopDefaultLegacy(httpProxy);
|
|
13
|
-
|
|
14
|
-
var proxyServer = httpProxy__default["default"].createProxyServer({});
|
|
15
|
-
function proxy(_a, handler) {
|
|
16
|
-
var _b = _a.props, to = _b.to, _c = _b.secure, secure = _c === void 0 ? false : _c;
|
|
17
|
-
var action = useAction.actionContext.get(handler);
|
|
18
|
-
if (!action) {
|
|
19
|
-
throw Error('Use <proxy> inside <action>');
|
|
20
|
-
}
|
|
21
|
-
var req = action.req, res = action.res;
|
|
22
|
-
delete req.headers.host;
|
|
23
|
-
proxyServer.web(req, res, { target: to, secure: secure });
|
|
24
|
-
return constants.CONTINUE;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
exports.proxy = proxy;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { actionContext } from '../../hooks/useAction/useAction.es6.js';
|
|
2
|
-
import '../../hooks/useServer/useServer.es6.js';
|
|
3
|
-
|
|
4
|
-
const redirectStatuses = {
|
|
5
|
-
multipleChoices: 300,
|
|
6
|
-
movedPermanently: 301,
|
|
7
|
-
found: 302,
|
|
8
|
-
seeOther: 303,
|
|
9
|
-
notModified: 304,
|
|
10
|
-
useProxy: 305,
|
|
11
|
-
temporaryRedirect: 307,
|
|
12
|
-
permanentRedirect: 308,
|
|
13
|
-
};
|
|
14
|
-
function getStatus(status) {
|
|
15
|
-
if (typeof status === 'number')
|
|
16
|
-
return status;
|
|
17
|
-
return redirectStatuses[status] || 301;
|
|
18
|
-
}
|
|
19
|
-
function customEncode(url) {
|
|
20
|
-
return encodeURI(url.replaceAll('%20', ' '));
|
|
21
|
-
}
|
|
22
|
-
function redirect({ props, children }, handler) {
|
|
23
|
-
const action = actionContext.get(handler);
|
|
24
|
-
if (!action) {
|
|
25
|
-
throw Error('Use <redirect> inside <action>');
|
|
26
|
-
}
|
|
27
|
-
const { to, status = 301, encode } = props;
|
|
28
|
-
action.res.writeHead(getStatus(status), {
|
|
29
|
-
location: encode ? customEncode(to) : to,
|
|
30
|
-
});
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { redirect, redirectStatuses };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var useAction = require('../../hooks/useAction/useAction.js');
|
|
6
|
-
require('../../hooks/useServer/useServer.js');
|
|
7
|
-
|
|
8
|
-
var redirectStatuses = {
|
|
9
|
-
multipleChoices: 300,
|
|
10
|
-
movedPermanently: 301,
|
|
11
|
-
found: 302,
|
|
12
|
-
seeOther: 303,
|
|
13
|
-
notModified: 304,
|
|
14
|
-
useProxy: 305,
|
|
15
|
-
temporaryRedirect: 307,
|
|
16
|
-
permanentRedirect: 308,
|
|
17
|
-
};
|
|
18
|
-
function getStatus(status) {
|
|
19
|
-
if (typeof status === 'number')
|
|
20
|
-
return status;
|
|
21
|
-
return redirectStatuses[status] || 301;
|
|
22
|
-
}
|
|
23
|
-
function customEncode(url) {
|
|
24
|
-
return encodeURI(url.replaceAll('%20', ' '));
|
|
25
|
-
}
|
|
26
|
-
function redirect(_a, handler) {
|
|
27
|
-
var props = _a.props; _a.children;
|
|
28
|
-
var action = useAction.actionContext.get(handler);
|
|
29
|
-
if (!action) {
|
|
30
|
-
throw Error('Use <redirect> inside <action>');
|
|
31
|
-
}
|
|
32
|
-
var to = props.to, _b = props.status, status = _b === void 0 ? 301 : _b, encode = props.encode;
|
|
33
|
-
action.res.writeHead(getStatus(status), {
|
|
34
|
-
location: encode ? customEncode(to) : to,
|
|
35
|
-
});
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
exports.redirect = redirect;
|
|
40
|
-
exports.redirectStatuses = redirectStatuses;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './router';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ROUTER, getMatchReg, router, useRouter } from './router.es6.js';
|
package/plugins/router/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var router = require('./router.js');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.ROUTER = router.ROUTER;
|
|
10
|
-
exports.getMatchReg = router.getMatchReg;
|
|
11
|
-
exports.router = router.router;
|
|
12
|
-
exports.useRouter = router.useRouter;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type Action } from 'src/utils';
|
|
2
|
-
export declare type Methods = 'GET' | 'HEAD' | 'POST' | 'DELETE' | 'PUT' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
|
|
3
|
-
export interface RouterProps {
|
|
4
|
-
method?: Methods;
|
|
5
|
-
path?: string;
|
|
6
|
-
prefix?: string;
|
|
7
|
-
ish?: boolean;
|
|
8
|
-
onMatch?: (action: Action) => void;
|
|
9
|
-
}
|
|
10
|
-
export declare function getMatchReg(props: RouterProps): string;
|
|
11
|
-
export interface Router {
|
|
12
|
-
prefix?: string;
|
|
13
|
-
params?: Record<string, string>;
|
|
14
|
-
}
|
|
15
|
-
export declare const ROUTER: string;
|
|
16
|
-
export declare function useRouter(): Router;
|
|
17
|
-
export declare function router({ props, children }: {
|
|
18
|
-
props: any;
|
|
19
|
-
children: any;
|
|
20
|
-
}, handler: any): any;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import innet from 'innet';
|
|
2
|
-
import { useHandler } from '@innet/jsx';
|
|
3
|
-
import { actionContext } from '../../hooks/useAction/useAction.es6.js';
|
|
4
|
-
import '../../hooks/useServer/useServer.es6.js';
|
|
5
|
-
|
|
6
|
-
function getMatchReg(props) {
|
|
7
|
-
const { ish, path } = props;
|
|
8
|
-
return `^${path}${ish ? '(?<rest>/.*)?' : ''}$`;
|
|
9
|
-
}
|
|
10
|
-
const ROUTER = Symbol('Parent Router');
|
|
11
|
-
function useRouter() {
|
|
12
|
-
return useHandler()[ROUTER];
|
|
13
|
-
}
|
|
14
|
-
function router({ props, children }, handler) {
|
|
15
|
-
var _a;
|
|
16
|
-
if (!children)
|
|
17
|
-
return;
|
|
18
|
-
if (!props)
|
|
19
|
-
return children;
|
|
20
|
-
const action = actionContext.get(handler);
|
|
21
|
-
if (!action) {
|
|
22
|
-
throw Error('Use <router> inside <action>');
|
|
23
|
-
}
|
|
24
|
-
const { req, path } = action;
|
|
25
|
-
if (props.method && props.method !== req.method) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const parent = handler[ROUTER];
|
|
29
|
-
const parentPrefix = (parent === null || parent === void 0 ? void 0 : parent.prefix) || '';
|
|
30
|
-
if (parentPrefix && !path.startsWith(parentPrefix)) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const url = parentPrefix ? path.slice(parentPrefix.length) : path;
|
|
34
|
-
const newHandler = Object.create(handler);
|
|
35
|
-
const current = newHandler[ROUTER] = Object.create(parent || null);
|
|
36
|
-
if (props.prefix) {
|
|
37
|
-
current.prefix = parentPrefix + props.prefix;
|
|
38
|
-
}
|
|
39
|
-
if (props.path) {
|
|
40
|
-
const urlReg = new RegExp(getMatchReg(props));
|
|
41
|
-
if (urlReg.test(url)) {
|
|
42
|
-
current.params = url.match(urlReg).groups;
|
|
43
|
-
}
|
|
44
|
-
else
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
(_a = props.onMatch) === null || _a === void 0 ? void 0 : _a.call(props, action);
|
|
48
|
-
return innet(children.length > 1 ? children : children[0], newHandler);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export { ROUTER, getMatchReg, router, useRouter };
|
package/plugins/router/router.js
DELETED
|
@@ -1,63 +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
|
-
var useAction = require('../../hooks/useAction/useAction.js');
|
|
8
|
-
require('../../hooks/useServer/useServer.js');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
-
|
|
12
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
13
|
-
|
|
14
|
-
function getMatchReg(props) {
|
|
15
|
-
var ish = props.ish, path = props.path;
|
|
16
|
-
return "^".concat(path).concat(ish ? '(?<rest>/.*)?' : '', "$");
|
|
17
|
-
}
|
|
18
|
-
var ROUTER = Symbol('Parent Router');
|
|
19
|
-
function useRouter() {
|
|
20
|
-
return jsx.useHandler()[ROUTER];
|
|
21
|
-
}
|
|
22
|
-
function router(_a, handler) {
|
|
23
|
-
var _b;
|
|
24
|
-
var props = _a.props, children = _a.children;
|
|
25
|
-
if (!children)
|
|
26
|
-
return;
|
|
27
|
-
if (!props)
|
|
28
|
-
return children;
|
|
29
|
-
var action = useAction.actionContext.get(handler);
|
|
30
|
-
if (!action) {
|
|
31
|
-
throw Error('Use <router> inside <action>');
|
|
32
|
-
}
|
|
33
|
-
var req = action.req, path = action.path;
|
|
34
|
-
if (props.method && props.method !== req.method) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
var parent = handler[ROUTER];
|
|
38
|
-
var parentPrefix = (parent === null || parent === void 0 ? void 0 : parent.prefix) || '';
|
|
39
|
-
if (parentPrefix && !path.startsWith(parentPrefix)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
var url = parentPrefix ? path.slice(parentPrefix.length) : path;
|
|
43
|
-
var newHandler = Object.create(handler);
|
|
44
|
-
var current = newHandler[ROUTER] = Object.create(parent || null);
|
|
45
|
-
if (props.prefix) {
|
|
46
|
-
current.prefix = parentPrefix + props.prefix;
|
|
47
|
-
}
|
|
48
|
-
if (props.path) {
|
|
49
|
-
var urlReg = new RegExp(getMatchReg(props));
|
|
50
|
-
if (urlReg.test(url)) {
|
|
51
|
-
current.params = url.match(urlReg).groups;
|
|
52
|
-
}
|
|
53
|
-
else
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
(_b = props.onMatch) === null || _b === void 0 ? void 0 : _b.call(props, action);
|
|
57
|
-
return innet__default["default"](children.length > 1 ? children : children[0], newHandler);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
exports.ROUTER = ROUTER;
|
|
61
|
-
exports.getMatchReg = getMatchReg;
|
|
62
|
-
exports.router = router;
|
|
63
|
-
exports.useRouter = useRouter;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { Handler } from 'innet';
|
|
4
|
-
import http from 'http';
|
|
5
|
-
import http2 from 'https';
|
|
6
|
-
import { Request, Response } from '../../utils';
|
|
7
|
-
export interface SSL {
|
|
8
|
-
cert: string;
|
|
9
|
-
key: string;
|
|
10
|
-
}
|
|
11
|
-
export interface ServerProps {
|
|
12
|
-
port?: number;
|
|
13
|
-
ssl?: SSL;
|
|
14
|
-
onStart?: (url: string) => any;
|
|
15
|
-
onRequest?: (req: Request, res: Response) => any;
|
|
16
|
-
onError?: (e: Error) => any;
|
|
17
|
-
onDestroy?: () => any;
|
|
18
|
-
}
|
|
19
|
-
export declare function server({ props, children }: {
|
|
20
|
-
props?: ServerProps;
|
|
21
|
-
children: any;
|
|
22
|
-
}, handler: Handler): http2.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import innet from 'innet';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import http from 'http';
|
|
4
|
-
import http2 from 'https';
|
|
5
|
-
import { onDestroy } from 'watch-state';
|
|
6
|
-
import '../../hooks/useAction/useAction.es6.js';
|
|
7
|
-
import { serverContext } from '../../hooks/useServer/useServer.es6.js';
|
|
8
|
-
|
|
9
|
-
const isInvalidPath = require('is-invalid-path');
|
|
10
|
-
function server({ props = {}, children }, handler) {
|
|
11
|
-
const { env } = process;
|
|
12
|
-
let { ssl: { key = env.SSL_KEY, cert = env.SSL_CRT } = {} } = props;
|
|
13
|
-
const childHandler = Object.create(handler);
|
|
14
|
-
if (!isInvalidPath(key)) {
|
|
15
|
-
key = fs.readFileSync(key).toString();
|
|
16
|
-
}
|
|
17
|
-
if (!isInvalidPath(cert)) {
|
|
18
|
-
cert = fs.readFileSync(cert).toString();
|
|
19
|
-
}
|
|
20
|
-
const https = Boolean(key && cert);
|
|
21
|
-
const { port = env.PORT || (https ? 442 : 80), onStart, onError, onRequest } = props;
|
|
22
|
-
const server = https ? http2.createServer({ key, cert }) : http.createServer();
|
|
23
|
-
childHandler[serverContext.key] = server;
|
|
24
|
-
onDestroy(() => {
|
|
25
|
-
var _a;
|
|
26
|
-
(_a = props.onDestroy) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
27
|
-
server.close();
|
|
28
|
-
});
|
|
29
|
-
if (onError) {
|
|
30
|
-
server.on('error', onError);
|
|
31
|
-
}
|
|
32
|
-
if (onRequest) {
|
|
33
|
-
server.on('request', onRequest);
|
|
34
|
-
}
|
|
35
|
-
innet(children, childHandler);
|
|
36
|
-
server.listen(port, () => {
|
|
37
|
-
const url = `http${https ? 's' : ''}://localhost:${port}`;
|
|
38
|
-
onStart === null || onStart === void 0 ? void 0 : onStart(url);
|
|
39
|
-
});
|
|
40
|
-
return server;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { server };
|
package/plugins/server/server.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var innet = require('innet');
|
|
6
|
-
var fs = require('fs');
|
|
7
|
-
var http = require('http');
|
|
8
|
-
var http2 = require('https');
|
|
9
|
-
var watchState = require('watch-state');
|
|
10
|
-
require('../../hooks/useAction/useAction.js');
|
|
11
|
-
var useServer = require('../../hooks/useServer/useServer.js');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
16
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
17
|
-
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
18
|
-
var http2__default = /*#__PURE__*/_interopDefaultLegacy(http2);
|
|
19
|
-
|
|
20
|
-
var isInvalidPath = require('is-invalid-path');
|
|
21
|
-
function server(_a, handler) {
|
|
22
|
-
var _b = _a.props, props = _b === void 0 ? {} : _b, children = _a.children;
|
|
23
|
-
var env = process.env;
|
|
24
|
-
var _c = props.ssl, _d = _c === void 0 ? {} : _c, _e = _d.key, key = _e === void 0 ? env.SSL_KEY : _e, _f = _d.cert, cert = _f === void 0 ? env.SSL_CRT : _f;
|
|
25
|
-
var childHandler = Object.create(handler);
|
|
26
|
-
if (!isInvalidPath(key)) {
|
|
27
|
-
key = fs__default["default"].readFileSync(key).toString();
|
|
28
|
-
}
|
|
29
|
-
if (!isInvalidPath(cert)) {
|
|
30
|
-
cert = fs__default["default"].readFileSync(cert).toString();
|
|
31
|
-
}
|
|
32
|
-
var https = Boolean(key && cert);
|
|
33
|
-
var _g = props.port, port = _g === void 0 ? env.PORT || (https ? 442 : 80) : _g, onStart = props.onStart, onError = props.onError, onRequest = props.onRequest;
|
|
34
|
-
var server = https ? http2__default["default"].createServer({ key: key, cert: cert }) : http__default["default"].createServer();
|
|
35
|
-
childHandler[useServer.serverContext.key] = server;
|
|
36
|
-
watchState.onDestroy(function () {
|
|
37
|
-
var _a;
|
|
38
|
-
(_a = props.onDestroy) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
39
|
-
server.close();
|
|
40
|
-
});
|
|
41
|
-
if (onError) {
|
|
42
|
-
server.on('error', onError);
|
|
43
|
-
}
|
|
44
|
-
if (onRequest) {
|
|
45
|
-
server.on('request', onRequest);
|
|
46
|
-
}
|
|
47
|
-
innet__default["default"](children, childHandler);
|
|
48
|
-
server.listen(port, function () {
|
|
49
|
-
var url = "http".concat(https ? 's' : '', "://localhost:").concat(port);
|
|
50
|
-
onStart === null || onStart === void 0 ? void 0 : onStart(url);
|
|
51
|
-
});
|
|
52
|
-
return server;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
exports.server = server;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import innet from 'innet';
|
|
2
|
-
import { actionContext } from '../../hooks/useAction/useAction.es6.js';
|
|
3
|
-
import '../../hooks/useServer/useServer.es6.js';
|
|
4
|
-
|
|
5
|
-
const successStatuses = {
|
|
6
|
-
ok: 200,
|
|
7
|
-
created: 201,
|
|
8
|
-
accepted: 202,
|
|
9
|
-
outside: 203,
|
|
10
|
-
noContent: 204,
|
|
11
|
-
resetContent: 205,
|
|
12
|
-
partialContent: 206,
|
|
13
|
-
multiStatus: 207,
|
|
14
|
-
alreadyReported: 208,
|
|
15
|
-
};
|
|
16
|
-
function success({ props, children }, handler) {
|
|
17
|
-
const action = actionContext.get(handler);
|
|
18
|
-
if (!action) {
|
|
19
|
-
throw Error('Use <success> inside <action>');
|
|
20
|
-
}
|
|
21
|
-
const status = props === null || props === void 0 ? void 0 : props.status;
|
|
22
|
-
action.res.statusCode = status
|
|
23
|
-
? successStatuses[status] || status
|
|
24
|
-
: children
|
|
25
|
-
? 200
|
|
26
|
-
: 204;
|
|
27
|
-
const data = innet(children, handler);
|
|
28
|
-
if (typeof data === 'object') {
|
|
29
|
-
return JSON.stringify(data);
|
|
30
|
-
}
|
|
31
|
-
return data !== null && data !== void 0 ? data : null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { success, successStatuses };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var innet = require('innet');
|
|
6
|
-
var useAction = require('../../hooks/useAction/useAction.js');
|
|
7
|
-
require('../../hooks/useServer/useServer.js');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
-
|
|
11
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
12
|
-
|
|
13
|
-
var successStatuses = {
|
|
14
|
-
ok: 200,
|
|
15
|
-
created: 201,
|
|
16
|
-
accepted: 202,
|
|
17
|
-
outside: 203,
|
|
18
|
-
noContent: 204,
|
|
19
|
-
resetContent: 205,
|
|
20
|
-
partialContent: 206,
|
|
21
|
-
multiStatus: 207,
|
|
22
|
-
alreadyReported: 208,
|
|
23
|
-
};
|
|
24
|
-
function success(_a, handler) {
|
|
25
|
-
var props = _a.props, children = _a.children;
|
|
26
|
-
var action = useAction.actionContext.get(handler);
|
|
27
|
-
if (!action) {
|
|
28
|
-
throw Error('Use <success> inside <action>');
|
|
29
|
-
}
|
|
30
|
-
var status = props === null || props === void 0 ? void 0 : props.status;
|
|
31
|
-
action.res.statusCode = status
|
|
32
|
-
? successStatuses[status] || status
|
|
33
|
-
: children
|
|
34
|
-
? 200
|
|
35
|
-
: 204;
|
|
36
|
-
var data = innet__default["default"](children, handler);
|
|
37
|
-
if (typeof data === 'object') {
|
|
38
|
-
return JSON.stringify(data);
|
|
39
|
-
}
|
|
40
|
-
return data !== null && data !== void 0 ? data : null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
exports.success = success;
|
|
44
|
-
exports.successStatuses = successStatuses;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './validation';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { validation, validationContext } from './validation.es6.js';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ValidationMap, ValidationResponse } from '@cantinc/utils';
|
|
2
|
-
import { Context } from '@innet/jsx';
|
|
3
|
-
import { Resources } from '../../utils';
|
|
4
|
-
export interface ValidationProps<T> {
|
|
5
|
-
map: ValidationMap<T>;
|
|
6
|
-
resource?: Resources;
|
|
7
|
-
}
|
|
8
|
-
export interface ValidationJsxElement<T> {
|
|
9
|
-
props: ValidationProps<T>;
|
|
10
|
-
children?: any;
|
|
11
|
-
}
|
|
12
|
-
export interface ValidationContext {
|
|
13
|
-
handleError?: (e: ValidationResponse<any>) => any;
|
|
14
|
-
}
|
|
15
|
-
export declare const validationContext: Context<ValidationContext, ValidationContext>;
|
|
16
|
-
export declare function validation<T extends object, E extends object>({ props, children }: ValidationJsxElement<T>, handler: any): any;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import innet from 'innet';
|
|
2
|
-
import { validation as validation$1 } from '@cantinc/utils';
|
|
3
|
-
import { Context } from '@innet/jsx';
|
|
4
|
-
import { actionContext } from '../../hooks/useAction/useAction.es6.js';
|
|
5
|
-
import '../../hooks/useServer/useServer.es6.js';
|
|
6
|
-
|
|
7
|
-
const validationContext = new Context({});
|
|
8
|
-
function validation({ props, children }, handler) {
|
|
9
|
-
const action = actionContext.get(handler);
|
|
10
|
-
if (!action) {
|
|
11
|
-
throw Error('Use <validation> inside <action>');
|
|
12
|
-
}
|
|
13
|
-
const { map, resource = 'body' } = props;
|
|
14
|
-
const run = () => {
|
|
15
|
-
const data = action[resource];
|
|
16
|
-
if (!data)
|
|
17
|
-
throw Error(`cannot find ${resource} in action`);
|
|
18
|
-
const result = validation$1(map, data);
|
|
19
|
-
if (result) {
|
|
20
|
-
const { handleError } = validationContext.get(handler);
|
|
21
|
-
return handleError ? innet(handleError(result), handler) : undefined;
|
|
22
|
-
}
|
|
23
|
-
return innet(children, handler);
|
|
24
|
-
};
|
|
25
|
-
if (resource === 'body' || resource === 'files') {
|
|
26
|
-
return action.parseBody().then(run);
|
|
27
|
-
}
|
|
28
|
-
return run();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { validation, validationContext };
|