raiton 1.0.0 → 3.0.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/CHANGELOG.md +39 -0
- package/README.md +97 -1
- package/build/bin/index.mjs +7012 -47
- package/deno.json +9 -0
- package/package.json +22 -43
- package/scripts/update-version.ts +97 -0
- package/source/bin/bootstrapper.ts +15 -0
- package/source/bin/cli-tools.ts +68 -0
- package/source/bin/cli.ts +12 -0
- package/source/bin/constants.ts +5 -0
- package/source/bin/index.ts +6 -0
- package/source/commands/artifact.command.ts +28 -0
- package/source/commands/build.command.ts +31 -0
- package/source/commands/develop.command.ts +47 -0
- package/source/commands/grafts.command.ts +27 -0
- package/source/commands/start.command.ts +28 -0
- package/source/core/application.ts +163 -0
- package/source/core/builder.ts +144 -0
- package/source/core/bytes.util.ts +17 -0
- package/source/core/command.ts +24 -0
- package/source/core/commands.ts +44 -0
- package/source/core/config/config.ts +51 -0
- package/source/core/config/define.ts +13 -0
- package/source/core/config/index.ts +2 -0
- package/source/core/context.ts +33 -0
- package/source/core/controller/builder.ts +41 -0
- package/source/core/controller/compiler.ts +22 -0
- package/source/core/controller/index.ts +3 -0
- package/source/core/controller/metadata.ts +13 -0
- package/source/core/directories.ts +30 -0
- package/source/core/helpers/index.ts +1 -0
- package/source/core/helpers/raiton.ts +3 -0
- package/source/core/hooks.ts +28 -0
- package/source/core/index.ts +14 -0
- package/source/core/injection/index.ts +1 -0
- package/source/core/injection/injection.ts +219 -0
- package/source/core/middleware/compose.ts +40 -0
- package/source/core/middleware/index.ts +2 -0
- package/source/core/middleware/pipeline.ts +27 -0
- package/source/core/plugins/index.ts +2 -0
- package/source/core/plugins/plugin.ts +8 -0
- package/source/core/plugins/scope.ts +46 -0
- package/source/core/process.util.ts +12 -0
- package/source/core/raiton.ts +20 -0
- package/source/core/router/handler.ts +115 -0
- package/source/core/router/index.ts +4 -0
- package/source/core/router/matcher.ts +51 -0
- package/source/core/router/route.ts +63 -0
- package/source/core/router/router.ts +31 -0
- package/source/core/server.ts +26 -0
- package/source/core/thread.ts +112 -0
- package/source/env.d.ts +3 -0
- package/source/requirements.ts +27 -0
- package/source/sdk/artifacts.ts +79 -0
- package/source/sdk/constants/decorators.constant.ts +8 -0
- package/source/sdk/constants/index.ts +2 -0
- package/source/sdk/constants/microservices.constant.ts +4 -0
- package/source/sdk/controllers.ts +4 -0
- package/source/sdk/data-transfer-object.ts +15 -0
- package/source/sdk/decorators/access-guard.decorator.ts +9 -0
- package/source/sdk/decorators/controllable.decorator.ts +20 -0
- package/source/sdk/decorators/index.ts +5 -0
- package/source/sdk/decorators/injection.decorator.ts +46 -0
- package/source/sdk/decorators/middleware.decorator.ts +15 -0
- package/source/sdk/decorators/parametrable.ts +28 -0
- package/source/sdk/decorators/routable.decorator.ts +45 -0
- package/source/sdk/encryption.ts +157 -0
- package/source/sdk/enums/encrypted.enum.ts +23 -0
- package/source/sdk/enums/event.message.enum.ts +4 -0
- package/source/sdk/enums/http-method.enum.ts +10 -0
- package/{build/sdk/enums/http-parameters.enum.d.ts → source/sdk/enums/http-parameters.enum.ts} +3 -5
- package/source/sdk/enums/http-status.enum.ts +73 -0
- package/source/sdk/enums/index.ts +7 -0
- package/{build/sdk/enums/runtime.enum.d.ts → source/sdk/enums/runtime.enum.ts} +2 -4
- package/{build/sdk/enums/timestamp.enum.d.ts → source/sdk/enums/timestamp.enum.ts} +2 -4
- package/source/sdk/env.ts +40 -0
- package/source/sdk/exceptions/http-exception.ts +28 -0
- package/source/sdk/exceptions/index.ts +2 -0
- package/{build/sdk/throwable.d.ts → source/sdk/exceptions/throwable.ts} +35 -12
- package/source/sdk/index.ts +14 -0
- package/source/sdk/parameter-bag.ts +55 -0
- package/source/sdk/plugins/body-parser.plugin.ts +160 -0
- package/source/sdk/plugins/index.ts +2 -0
- package/source/sdk/plugins/security/body-limit.ts +19 -0
- package/source/sdk/plugins/security/cors.ts +44 -0
- package/source/sdk/plugins/security/headers.ts +14 -0
- package/source/sdk/plugins/security/index.ts +13 -0
- package/source/sdk/plugins/security/method-guard.ts +14 -0
- package/source/sdk/plugins/security/rate-limit.ts +42 -0
- package/source/sdk/repositories.ts +14 -0
- package/source/sdk/responses/error.ts +52 -0
- package/source/sdk/responses/helpers.ts +28 -0
- package/source/sdk/responses/http-throwable.ts +28 -0
- package/source/sdk/responses/http.ts +48 -0
- package/source/sdk/responses/index.ts +4 -0
- package/source/sdk/runtime/bun/server.ts +73 -0
- package/source/sdk/runtime/deno/server.ts +53 -0
- package/source/sdk/runtime/index.ts +47 -0
- package/source/sdk/runtime/node/server.ts +60 -0
- package/source/sdk/runtime/web/server.ts +57 -0
- package/source/sdk/services.ts +9 -0
- package/source/sdk/utilities/alias-path.util.ts +49 -0
- package/source/sdk/utilities/artifact.util.ts +18 -0
- package/source/sdk/utilities/callable.util.ts +27 -0
- package/source/sdk/utilities/index.ts +5 -0
- package/source/sdk/utilities/json.util.ts +21 -0
- package/source/sdk/utilities/path.util.ts +19 -0
- package/source/sdk/utilities/url.ts +5 -0
- package/source/sdk/utilities/utilities.util.ts +25 -0
- package/source/types/access-guards.ts +4 -0
- package/{build/types/application.d.ts → source/types/application.ts} +23 -7
- package/source/types/artifact.ts +44 -0
- package/source/types/builder.ts +44 -0
- package/source/types/config.ts +7 -0
- package/source/types/controller.ts +33 -0
- package/source/types/contruct.ts +3 -0
- package/source/types/core.ts +28 -0
- package/{build/types/directory.d.ts → source/types/directory.ts} +4 -4
- package/source/types/encryption.ts +17 -0
- package/source/types/generic.ts +3 -0
- package/source/types/http-responses.ts +8 -0
- package/source/types/index.ts +25 -0
- package/source/types/injection.ts +13 -0
- package/source/types/lifecycle.ts +11 -0
- package/source/types/middleware.ts +18 -0
- package/source/types/parseable.ts +7 -0
- package/source/types/plugin.ts +10 -0
- package/source/types/raiton.ts +7 -0
- package/source/types/responses.ts +20 -0
- package/source/types/router.ts +11 -0
- package/source/types/runtime.ts +56 -0
- package/{build/types/scheme.d.ts → source/types/scheme.ts} +33 -8
- package/source/types/server.ts +12 -0
- package/source/types/thread.ts +31 -0
- package/source/types/utilities.ts +4 -0
- package/source/types/values.ts +3 -0
- package/.releaserc.json +0 -39
- package/build/bin/bootstrapper.d.ts +0 -5
- package/build/bin/bootstrapper.mjs +0 -46
- package/build/bin/cli.d.ts +0 -5
- package/build/bin/cli.mjs +0 -6
- package/build/bin/index.d.ts +0 -1
- package/build/chunk-3PWMRP6G.mjs +0 -16
- package/build/chunk-52JR26TI.mjs +0 -29
- package/build/chunk-5LNOA4SK.mjs +0 -16
- package/build/chunk-AUGL35CF.mjs +0 -24
- package/build/chunk-BEV2YOPG.mjs +0 -14
- package/build/chunk-BYYJRCB4.mjs +0 -10
- package/build/chunk-FFRJ4AUA.mjs +0 -16
- package/build/chunk-GPJSLV3Q.mjs +0 -50
- package/build/chunk-HVFHDVAH.mjs +0 -20
- package/build/chunk-IOCHNQMF.mjs +0 -13
- package/build/chunk-JATYBWHL.mjs +0 -36
- package/build/chunk-JWNBO7XV.mjs +0 -53
- package/build/chunk-K4IQQ2KF.mjs +0 -55
- package/build/chunk-K4KLOLSO.mjs +0 -645
- package/build/chunk-M2RZZJQR.mjs +0 -27
- package/build/chunk-MLFGBJDV.mjs +0 -12
- package/build/chunk-NB62GSFI.mjs +0 -27
- package/build/chunk-O7R3NJQN.mjs +0 -19
- package/build/chunk-P3IRIFPT.mjs +0 -53
- package/build/chunk-QFSXFOEN.mjs +0 -56
- package/build/chunk-QHCQ4AUA.mjs +0 -14
- package/build/chunk-QI7OFSXB.mjs +0 -37
- package/build/chunk-RVH2YBNU.mjs +0 -111
- package/build/chunk-RXG7754R.mjs +0 -25
- package/build/chunk-S3ONGVNZ.mjs +0 -11
- package/build/chunk-SRR4467I.mjs +0 -29
- package/build/chunk-T6L55AUG.mjs +0 -32
- package/build/chunk-TOJFTPAY.mjs +0 -83
- package/build/chunk-UAPCBU3J.mjs +0 -12
- package/build/chunk-UCHBN3DV.mjs +0 -52
- package/build/chunk-UWM46HLZ.mjs +0 -18
- package/build/chunk-UZFCGVHP.mjs +0 -8
- package/build/chunk-VQINCGLQ.mjs +0 -59
- package/build/chunk-VRL4S7UF.mjs +0 -74
- package/build/chunk-WAWFDMOH.mjs +0 -72
- package/build/chunk-X3JFRRRQ.mjs +0 -45
- package/build/chunk-XFBLELHI.mjs +0 -34
- package/build/chunk-XIGE72LC.mjs +0 -34
- package/build/chunk-XW7EPAD7.mjs +0 -0
- package/build/chunk-YGIZFKLJ.mjs +0 -20
- package/build/chunk-YRVIAORI.mjs +0 -8
- package/build/chunk-YXU5W2CB.mjs +0 -12
- package/build/commands/artifact.command.d.ts +0 -14
- package/build/commands/artifact.command.mjs +0 -59
- package/build/commands/build.command.d.ts +0 -14
- package/build/commands/build.command.mjs +0 -65
- package/build/commands/develop.command.d.ts +0 -13
- package/build/commands/develop.command.mjs +0 -75
- package/build/commands/grafts.command.d.ts +0 -12
- package/build/commands/grafts.command.mjs +0 -58
- package/build/commands/start.command.d.ts +0 -12
- package/build/commands/start.command.mjs +0 -64
- package/build/core/application.d.ts +0 -27
- package/build/core/application.mjs +0 -124
- package/build/core/artifact.d.ts +0 -19
- package/build/core/artifact.mjs +0 -133
- package/build/core/builder.d.ts +0 -35
- package/build/core/builder.mjs +0 -45
- package/build/core/bytes.util.d.ts +0 -6
- package/build/core/bytes.util.mjs +0 -8
- package/build/core/command.d.ts +0 -15
- package/build/core/command.mjs +0 -6
- package/build/core/commands.d.ts +0 -13
- package/build/core/commands.mjs +0 -7
- package/build/core/config.d.ts +0 -10
- package/build/core/config.mjs +0 -7
- package/build/core/context.d.ts +0 -15
- package/build/core/context.mjs +0 -6
- package/build/core/controller/builder.d.ts +0 -10
- package/build/core/controller/builder.mjs +0 -45
- package/build/core/controller/compiler.d.ts +0 -6
- package/build/core/controller/compiler.mjs +0 -45
- package/build/core/controller/index.d.ts +0 -13
- package/build/core/controller/index.mjs +0 -50
- package/build/core/controller/metadata.d.ts +0 -10
- package/build/core/controller/metadata.mjs +0 -6
- package/build/core/directories.d.ts +0 -11
- package/build/core/directories.mjs +0 -8
- package/build/core/hmr.d.ts +0 -22
- package/build/core/hmr.mjs +0 -6
- package/build/core/hooks.d.ts +0 -12
- package/build/core/hooks.mjs +0 -6
- package/build/core/index.d.ts +0 -41
- package/build/core/index.mjs +0 -100
- package/build/core/middleware/compose.d.ts +0 -8
- package/build/core/middleware/compose.mjs +0 -6
- package/build/core/middleware/index.d.ts +0 -6
- package/build/core/middleware/index.mjs +0 -11
- package/build/core/middleware/pipeline.d.ts +0 -14
- package/build/core/middleware/pipeline.mjs +0 -7
- package/build/core/plugins/index.d.ts +0 -14
- package/build/core/plugins/index.mjs +0 -48
- package/build/core/plugins/plugin.d.ts +0 -17
- package/build/core/plugins/plugin.mjs +0 -6
- package/build/core/plugins/scope.d.ts +0 -24
- package/build/core/plugins/scope.mjs +0 -45
- package/build/core/process.util.d.ts +0 -3
- package/build/core/process.util.mjs +0 -6
- package/build/core/raiton.d.ts +0 -20
- package/build/core/raiton.mjs +0 -6
- package/build/core/router/handler.d.ts +0 -10
- package/build/core/router/handler.mjs +0 -45
- package/build/core/router/index.d.ts +0 -12
- package/build/core/router/index.mjs +0 -54
- package/build/core/router/matcher.d.ts +0 -21
- package/build/core/router/matcher.mjs +0 -6
- package/build/core/router/route.d.ts +0 -20
- package/build/core/router/route.mjs +0 -6
- package/build/core/router/router.d.ts +0 -16
- package/build/core/router/router.mjs +0 -8
- package/build/core/thread.d.ts +0 -30
- package/build/core/thread.mjs +0 -45
- package/build/env.d.d.ts +0 -2
- package/build/env.d.mjs +0 -0
- package/build/raiton-1.0.0.tgz +0 -0
- package/build/requirements.d.ts +0 -2
- package/build/requirements.mjs +0 -19
- package/build/sdk/artifacts.d.ts +0 -13
- package/build/sdk/artifacts.mjs +0 -45
- package/build/sdk/constants/decorators.constant.d.ts +0 -11
- package/build/sdk/constants/decorators.constant.mjs +0 -6
- package/build/sdk/constants/index.d.ts +0 -2
- package/build/sdk/constants/index.mjs +0 -11
- package/build/sdk/constants/microservices.constant.d.ts +0 -5
- package/build/sdk/constants/microservices.constant.mjs +0 -6
- package/build/sdk/controllers.d.ts +0 -4
- package/build/sdk/controllers.mjs +0 -6
- package/build/sdk/data-transfer-object.d.ts +0 -7
- package/build/sdk/data-transfer-object.mjs +0 -7
- package/build/sdk/decorators/access-guard.decorator.d.ts +0 -2
- package/build/sdk/decorators/access-guard.decorator.mjs +0 -0
- package/build/sdk/decorators/controllable.d.ts +0 -3
- package/build/sdk/decorators/controllable.mjs +0 -45
- package/build/sdk/decorators/controllers.decorator.d.ts +0 -2
- package/build/sdk/decorators/controllers.decorator.mjs +0 -0
- package/build/sdk/decorators/grafts.decorator.d.ts +0 -2
- package/build/sdk/decorators/grafts.decorator.mjs +0 -0
- package/build/sdk/decorators/index.d.ts +0 -3
- package/build/sdk/decorators/index.mjs +0 -75
- package/build/sdk/decorators/parameters.decorator.d.ts +0 -2
- package/build/sdk/decorators/parameters.decorator.mjs +0 -0
- package/build/sdk/decorators/parametrable.d.ts +0 -9
- package/build/sdk/decorators/parametrable.mjs +0 -57
- package/build/sdk/decorators/payload.decorator.d.ts +0 -2
- package/build/sdk/decorators/payload.decorator.mjs +0 -0
- package/build/sdk/decorators/routable.d.ts +0 -10
- package/build/sdk/decorators/routable.mjs +0 -59
- package/build/sdk/dependency-container.d.ts +0 -19
- package/build/sdk/dependency-container.mjs +0 -46
- package/build/sdk/encryption.d.ts +0 -27
- package/build/sdk/encryption.mjs +0 -141
- package/build/sdk/enums/encrypted.enum.d.ts +0 -15
- package/build/sdk/enums/encrypted.enum.mjs +0 -6
- package/build/sdk/enums/event.message.enum.d.ts +0 -6
- package/build/sdk/enums/event.message.enum.mjs +0 -6
- package/build/sdk/enums/http-parameters.enum.mjs +0 -6
- package/build/sdk/enums/http.enum.d.ts +0 -12
- package/build/sdk/enums/http.enum.mjs +0 -6
- package/build/sdk/enums/index.d.ts +0 -6
- package/build/sdk/enums/index.mjs +0 -27
- package/build/sdk/enums/runtime.enum.mjs +0 -6
- package/build/sdk/enums/timestamp.enum.mjs +0 -6
- package/build/sdk/env.d.ts +0 -6
- package/build/sdk/env.mjs +0 -74
- package/build/sdk/fastify.d.ts +0 -11
- package/build/sdk/fastify.mjs +0 -9
- package/build/sdk/grafts.d.ts +0 -15
- package/build/sdk/grafts.mjs +0 -71
- package/build/sdk/index.d.ts +0 -34
- package/build/sdk/index.mjs +0 -126
- package/build/sdk/json.d.ts +0 -17
- package/build/sdk/json.mjs +0 -87
- package/build/sdk/plugins/body-parser.plugin.d.ts +0 -17
- package/build/sdk/plugins/body-parser.plugin.mjs +0 -7
- package/build/sdk/plugins/index.d.ts +0 -17
- package/build/sdk/plugins/index.mjs +0 -48
- package/build/sdk/plugins/security/body-limit.d.ts +0 -17
- package/build/sdk/plugins/security/body-limit.mjs +0 -45
- package/build/sdk/plugins/security/cors.d.ts +0 -22
- package/build/sdk/plugins/security/cors.mjs +0 -45
- package/build/sdk/plugins/security/headers.d.ts +0 -17
- package/build/sdk/plugins/security/headers.mjs +0 -45
- package/build/sdk/plugins/security/index.d.ts +0 -25
- package/build/sdk/plugins/security/index.mjs +0 -45
- package/build/sdk/plugins/security/method-guard.d.ts +0 -17
- package/build/sdk/plugins/security/method-guard.mjs +0 -45
- package/build/sdk/plugins/security/rate-limit.d.ts +0 -21
- package/build/sdk/plugins/security/rate-limit.mjs +0 -45
- package/build/sdk/repositories.d.ts +0 -7
- package/build/sdk/repositories.mjs +0 -17
- package/build/sdk/request.d.ts +0 -4
- package/build/sdk/request.mjs +0 -6
- package/build/sdk/responses.d.ts +0 -8
- package/build/sdk/responses.mjs +0 -20
- package/build/sdk/routes.d.ts +0 -7
- package/build/sdk/routes.mjs +0 -61
- package/build/sdk/runtime/bun/server.d.ts +0 -6
- package/build/sdk/runtime/bun/server.mjs +0 -6
- package/build/sdk/runtime/deno/server.d.ts +0 -6
- package/build/sdk/runtime/deno/server.mjs +0 -6
- package/build/sdk/runtime/index.d.ts +0 -15
- package/build/sdk/runtime/index.mjs +0 -11
- package/build/sdk/runtime/node/reply.d.ts +0 -2
- package/build/sdk/runtime/node/reply.mjs +0 -0
- package/build/sdk/runtime/node/request.d.ts +0 -2
- package/build/sdk/runtime/node/request.mjs +0 -0
- package/build/sdk/runtime/node/server.d.ts +0 -6
- package/build/sdk/runtime/node/server.mjs +0 -6
- package/build/sdk/runtime/web/server.d.ts +0 -6
- package/build/sdk/runtime/web/server.mjs +0 -6
- package/build/sdk/schemes.d.ts +0 -120
- package/build/sdk/schemes.mjs +0 -129
- package/build/sdk/services.d.ts +0 -8
- package/build/sdk/services.mjs +0 -10
- package/build/sdk/throwable.mjs +0 -14
- package/build/sdk/utilities/alias-path.util.d.ts +0 -9
- package/build/sdk/utilities/alias-path.util.mjs +0 -6
- package/build/sdk/utilities/artifacts.util.d.ts +0 -3
- package/build/sdk/utilities/artifacts.util.mjs +0 -45
- package/build/sdk/utilities/callable.util.d.ts +0 -3
- package/build/sdk/utilities/callable.util.mjs +0 -6
- package/build/sdk/utilities/controller.util.d.ts +0 -3
- package/build/sdk/utilities/controller.util.mjs +0 -6
- package/build/sdk/utilities/index.d.ts +0 -7
- package/build/sdk/utilities/index.mjs +0 -62
- package/build/sdk/utilities/json.util.d.ts +0 -3
- package/build/sdk/utilities/json.util.mjs +0 -6
- package/build/sdk/utilities/parameters-arguments.util.d.ts +0 -2
- package/build/sdk/utilities/parameters-arguments.util.mjs +0 -0
- package/build/sdk/utilities/url.d.ts +0 -3
- package/build/sdk/utilities/url.mjs +0 -7
- package/build/sdk/utilities/utilities.util.d.ts +0 -6
- package/build/sdk/utilities/utilities.util.mjs +0 -8
- package/build/types/access-guards.d.ts +0 -6
- package/build/types/access-guards.mjs +0 -0
- package/build/types/application.mjs +0 -0
- package/build/types/artifact.d.ts +0 -21
- package/build/types/artifact.mjs +0 -0
- package/build/types/builder.d.ts +0 -32
- package/build/types/builder.mjs +0 -0
- package/build/types/config.d.ts +0 -6
- package/build/types/config.mjs +0 -0
- package/build/types/controller.d.ts +0 -25
- package/build/types/controller.mjs +0 -0
- package/build/types/contruct.d.ts +0 -3
- package/build/types/contruct.mjs +0 -0
- package/build/types/core.d.ts +0 -15
- package/build/types/core.mjs +0 -0
- package/build/types/data-transfer-object.d.ts +0 -5
- package/build/types/data-transfer-object.mjs +0 -0
- package/build/types/dependency-container.d.ts +0 -20
- package/build/types/dependency-container.mjs +0 -0
- package/build/types/directory.mjs +0 -0
- package/build/types/encryption.d.ts +0 -16
- package/build/types/encryption.mjs +0 -0
- package/build/types/generic.d.ts +0 -4
- package/build/types/generic.mjs +0 -0
- package/build/types/hmr.d.ts +0 -25
- package/build/types/hmr.mjs +0 -0
- package/build/types/http-responses.d.ts +0 -10
- package/build/types/http-responses.mjs +0 -0
- package/build/types/index.d.ts +0 -45
- package/build/types/index.mjs +0 -0
- package/build/types/middleware.d.ts +0 -12
- package/build/types/middleware.mjs +0 -0
- package/build/types/parameters.d.ts +0 -19
- package/build/types/parameters.mjs +0 -0
- package/build/types/parseable.d.ts +0 -5
- package/build/types/parseable.mjs +0 -0
- package/build/types/payload.d.ts +0 -6
- package/build/types/payload.mjs +0 -0
- package/build/types/plugin.d.ts +0 -20
- package/build/types/plugin.mjs +0 -0
- package/build/types/raiton.d.ts +0 -12
- package/build/types/raiton.mjs +0 -0
- package/build/types/repositories.d.ts +0 -8
- package/build/types/repositories.mjs +0 -0
- package/build/types/router.d.ts +0 -14
- package/build/types/router.mjs +0 -0
- package/build/types/runtime.d.ts +0 -37
- package/build/types/runtime.mjs +0 -0
- package/build/types/scheme.mjs +0 -0
- package/build/types/server.d.ts +0 -57
- package/build/types/server.mjs +0 -0
- package/build/types/services.d.ts +0 -8
- package/build/types/services.mjs +0 -0
- package/build/types/thread.d.ts +0 -24
- package/build/types/thread.mjs +0 -0
- package/build/types/utilities.d.ts +0 -6
- package/build/types/utilities.mjs +0 -0
- package/build/types/values.d.ts +0 -4
- package/build/types/values.mjs +0 -0
- /package/{build/chunk-4OWCGDUD.mjs → source/sdk/runtime/node/reply.ts} +0 -0
- /package/{build/chunk-DIWD7ZCJ.mjs → source/sdk/runtime/node/request.ts} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {Throwable} from "@/sdk/exceptions";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class DelegateRepository {
|
|
5
|
+
protected readonly client: any;
|
|
6
|
+
public readonly model!: any;
|
|
7
|
+
|
|
8
|
+
protected supported(method: string): boolean {
|
|
9
|
+
if (typeof this.model !== 'object') throw new Throwable('Model not found, please check your repository')
|
|
10
|
+
else if (!(method in this.model)) throw new Throwable(`Method ${method} not found, please check your repository`)
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type {ErrorResponseInterface} from "@/types";
|
|
2
|
+
import {HttpResponse} from "@/sdk/responses/http";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class HttpErrorResponse {
|
|
6
|
+
public readonly stack: Map<string, ErrorResponseInterface> = new Map();
|
|
7
|
+
|
|
8
|
+
public get entries(): ErrorResponseInterface[] {
|
|
9
|
+
return [...this.stack.values()];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public add(input: ErrorResponseInterface): this {
|
|
13
|
+
this.stack.set(input.id, input)
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public remove(id: string): this {
|
|
18
|
+
this.stack.delete(id);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public get(id: string): ErrorResponseInterface | undefined {
|
|
23
|
+
return this.stack.get(id);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public has(id: string): boolean {
|
|
27
|
+
return this.stack.has(id);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public clear(): this {
|
|
31
|
+
this.stack.clear();
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public get empty(): boolean {
|
|
36
|
+
return this.stack.size === 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public get existence(): number {
|
|
40
|
+
return this.stack.size
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public push() {
|
|
44
|
+
const first = this.stack.values().next().value;
|
|
45
|
+
HttpResponse.push({
|
|
46
|
+
statusCode: 500,
|
|
47
|
+
message: first?.message || 'Internal server error',
|
|
48
|
+
error: true,
|
|
49
|
+
errorStack: this.entries
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {HttpResponse, HttpStatus} from "@/sdk";
|
|
2
|
+
import {HttpResponseInterface} from "@/types";
|
|
3
|
+
import {Raiton} from "@/core";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export function RaitonResponses(
|
|
7
|
+
message: string,
|
|
8
|
+
data: HttpResponseInterface,
|
|
9
|
+
statusCode: HttpStatus,
|
|
10
|
+
metadata?: Omit<HttpResponseInterface<any>, 'data' | 'message' | 'statusCode'>
|
|
11
|
+
) {
|
|
12
|
+
|
|
13
|
+
if (metadata) {
|
|
14
|
+
metadata.error = typeof data.error === 'boolean' ? data.error : false
|
|
15
|
+
metadata.errorStack = (metadata.errorStack instanceof Error)
|
|
16
|
+
? metadata.errorStack
|
|
17
|
+
: (Raiton.thread?.builder?.options?.development
|
|
18
|
+
? (Array.isArray(metadata.errorStack) ? metadata.errorStack : [])
|
|
19
|
+
: undefined)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
...metadata,
|
|
24
|
+
statusCode,
|
|
25
|
+
message,
|
|
26
|
+
data,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {HttpResponseInterface} from "@/types";
|
|
2
|
+
import {HttpStatus} from "@/sdk/enums";
|
|
3
|
+
import {Raiton} from "@/core";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class ThrowableResponse extends Error {
|
|
7
|
+
constructor(
|
|
8
|
+
public input: string | HttpResponseInterface,
|
|
9
|
+
public statusCode: HttpStatus = HttpStatus.INTERNAL_SERVER_ERROR,
|
|
10
|
+
) {
|
|
11
|
+
super(typeof input === 'string' ? input : input.message);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
render() {
|
|
15
|
+
const stack = typeof this.input === 'object' ? this.input.errorStack : undefined
|
|
16
|
+
return {
|
|
17
|
+
message: this.message,
|
|
18
|
+
statusCode: this.statusCode,
|
|
19
|
+
data: (typeof this.input === 'object') ? this.input.data : undefined,
|
|
20
|
+
error: (typeof this.input === 'object') ? this.input.error : false,
|
|
21
|
+
stack: stack instanceof Error ?
|
|
22
|
+
(Raiton.thread?.builder?.options?.development
|
|
23
|
+
? this.stack?.split('\n').map(e => e.trim())
|
|
24
|
+
: undefined)
|
|
25
|
+
: stack
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {HttpResponseInterface} from "@/types";
|
|
2
|
+
import {HttpStatus} from "@/sdk/enums";
|
|
3
|
+
import {ThrowableResponse} from "@/sdk/responses";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class HttpResponse {
|
|
7
|
+
public static push(response: Partial<HttpResponseInterface>): void {
|
|
8
|
+
throw new ThrowableResponse({
|
|
9
|
+
statusCode: response.statusCode || HttpStatus.BAD_REQUEST,
|
|
10
|
+
message: response.message || 'No response message provided',
|
|
11
|
+
data: response.data,
|
|
12
|
+
error: response.error,
|
|
13
|
+
errorStack: response.errorStack
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor(public readonly response: HttpResponseInterface) {
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
status(statusCode: HttpStatus): this {
|
|
21
|
+
this.response.statusCode = statusCode;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
message(message: string) {
|
|
26
|
+
this.response.message = message;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
data(data: any) {
|
|
31
|
+
this.response.data = data;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
error(error: boolean) {
|
|
36
|
+
this.response.error = error;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
stack(stack: Error) {
|
|
41
|
+
this.response.errorStack = stack
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
render(): HttpResponseInterface {
|
|
46
|
+
return (new ThrowableResponse({...this.response})).render()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {RuntimeAdapterInterface} from '@/types'
|
|
2
|
+
|
|
3
|
+
export const bunRuntime: RuntimeAdapterInterface = {
|
|
4
|
+
createServer(handler) {
|
|
5
|
+
if (typeof Bun === 'undefined') throw new Error(
|
|
6
|
+
'bun is not installed, please run `npm install bun`'
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
let server: any
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
async listen(port, hostname) {
|
|
13
|
+
server = Bun.serve({
|
|
14
|
+
port,
|
|
15
|
+
hostname,
|
|
16
|
+
fetch: async (request: Request) => {
|
|
17
|
+
let responseBody: any
|
|
18
|
+
let statusCode = 200
|
|
19
|
+
const headers = new Headers()
|
|
20
|
+
|
|
21
|
+
await handler(
|
|
22
|
+
{
|
|
23
|
+
method: request.method,
|
|
24
|
+
url: request.url,
|
|
25
|
+
headers: request.headers as any,
|
|
26
|
+
body: request.body as any
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
status(code) {
|
|
30
|
+
statusCode = code
|
|
31
|
+
},
|
|
32
|
+
header(name, value) {
|
|
33
|
+
headers.set(name, value)
|
|
34
|
+
},
|
|
35
|
+
send(body: any) {
|
|
36
|
+
if (body === undefined) {
|
|
37
|
+
responseBody = ''
|
|
38
|
+
} else if (typeof body === 'string' || Buffer.isBuffer(body)) {
|
|
39
|
+
responseBody = body;
|
|
40
|
+
} else {
|
|
41
|
+
headers.set('content-type', 'application/json');
|
|
42
|
+
responseBody = (JSON.stringify(body));
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
text(text: string | Buffer) {
|
|
46
|
+
responseBody = text
|
|
47
|
+
},
|
|
48
|
+
json(json: any) {
|
|
49
|
+
headers.set('content-type', 'application/json')
|
|
50
|
+
responseBody = JSON.stringify(json)
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
if (responseBody instanceof Response) {
|
|
56
|
+
return responseBody;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return new Response(
|
|
60
|
+
typeof responseBody === 'object' && !(responseBody instanceof Buffer)
|
|
61
|
+
? JSON.stringify(responseBody)
|
|
62
|
+
: responseBody,
|
|
63
|
+
{status: statusCode, headers}
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
},
|
|
68
|
+
async close() {
|
|
69
|
+
server?.stop()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {RuntimeAdapterInterface} from '@/types'
|
|
2
|
+
|
|
3
|
+
export const denoRuntime: RuntimeAdapterInterface = {
|
|
4
|
+
createServer(handler) {
|
|
5
|
+
let controller: AbortController
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
async listen(port, hostname) {
|
|
9
|
+
if (typeof Deno === 'undefined') throw new Error(
|
|
10
|
+
'Deno is not installed, please run `deno install -A -f --unstable https://deno.land/x/raiton/cli.ts`'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
controller = new AbortController()
|
|
14
|
+
Deno.serve({port, hostname, signal: controller.signal}, async (req: any) => {
|
|
15
|
+
let body: any
|
|
16
|
+
let status = 200
|
|
17
|
+
const headers = new Headers()
|
|
18
|
+
|
|
19
|
+
await handler(
|
|
20
|
+
{
|
|
21
|
+
method: req.method,
|
|
22
|
+
url: req.url,
|
|
23
|
+
headers: req.headers,
|
|
24
|
+
body: req.body
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
status(code) {
|
|
28
|
+
status = code
|
|
29
|
+
},
|
|
30
|
+
header(name, value) {
|
|
31
|
+
headers.set(name, value)
|
|
32
|
+
},
|
|
33
|
+
send(value: any) {
|
|
34
|
+
body = value
|
|
35
|
+
},
|
|
36
|
+
text(text: string | Buffer) {
|
|
37
|
+
body = text
|
|
38
|
+
},
|
|
39
|
+
json(json: any) {
|
|
40
|
+
body = JSON.stringify(json)
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return new Response(body, {status, headers})
|
|
46
|
+
})
|
|
47
|
+
},
|
|
48
|
+
async close() {
|
|
49
|
+
controller.abort()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type {RuntimeAdapterInterface, RuntimeHandlerCallable, RuntimeInterface, RuntimeServerInterface} from "@/types";
|
|
2
|
+
import {RuntimeType} from "@/sdk/enums/runtime.enum";
|
|
3
|
+
import {nodeRuntime} from "@/sdk/runtime/node/server";
|
|
4
|
+
import {bunRuntime} from "@/sdk/runtime/bun/server";
|
|
5
|
+
import {denoRuntime} from "@/sdk/runtime/deno/server";
|
|
6
|
+
import {webRuntime} from "@/sdk/runtime/web/server";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class Runtime implements RuntimeInterface {
|
|
10
|
+
constructor(
|
|
11
|
+
public readonly type: RuntimeType = RuntimeType.Node
|
|
12
|
+
) {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get isNode(): boolean {
|
|
16
|
+
return this.type === RuntimeType.Node;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get isDeno(): boolean {
|
|
20
|
+
return this.type === RuntimeType.Deno;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get isWeb(): boolean {
|
|
24
|
+
return this.type === RuntimeType.Web;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get isBun(): boolean {
|
|
28
|
+
return this.type === RuntimeType.Bun;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
adapter(): RuntimeAdapterInterface {
|
|
32
|
+
switch (this.type) {
|
|
33
|
+
case RuntimeType.Node:
|
|
34
|
+
return nodeRuntime
|
|
35
|
+
case RuntimeType.Bun:
|
|
36
|
+
return bunRuntime
|
|
37
|
+
case RuntimeType.Deno:
|
|
38
|
+
return denoRuntime
|
|
39
|
+
case RuntimeType.Web:
|
|
40
|
+
return webRuntime
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
createServer(handler: RuntimeHandlerCallable): RuntimeServerInterface {
|
|
45
|
+
return this.adapter().createServer(handler)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import http from 'node:http'
|
|
2
|
+
import {
|
|
3
|
+
RuntimeAdapterInterface,
|
|
4
|
+
RuntimeRequestInterface,
|
|
5
|
+
RuntimeReplyInterface
|
|
6
|
+
} from '@/types'
|
|
7
|
+
|
|
8
|
+
export const nodeRuntime: RuntimeAdapterInterface = {
|
|
9
|
+
createServer(handler) {
|
|
10
|
+
const server = http.createServer(async (req, res) => {
|
|
11
|
+
const runtimeReq: RuntimeRequestInterface = {
|
|
12
|
+
method: req.method || 'GET',
|
|
13
|
+
url: req.url || '/',
|
|
14
|
+
headers: new Headers(req.headers as any),
|
|
15
|
+
body: req as any,
|
|
16
|
+
remoteAddress: req.socket.remoteAddress
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const runtimeReply: RuntimeReplyInterface = {
|
|
20
|
+
status(code) {
|
|
21
|
+
res.statusCode = code
|
|
22
|
+
},
|
|
23
|
+
header(name, value) {
|
|
24
|
+
res.setHeader(name, value)
|
|
25
|
+
},
|
|
26
|
+
send(body: any) {
|
|
27
|
+
if (body === undefined) {
|
|
28
|
+
res.end()
|
|
29
|
+
} else if (typeof body === 'string' || Buffer.isBuffer(body)) {
|
|
30
|
+
res.end(body)
|
|
31
|
+
} else {
|
|
32
|
+
res.setHeader('content-type', 'application/json')
|
|
33
|
+
res.end(JSON.stringify(body))
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
text(text: string|Buffer) {
|
|
37
|
+
res.end(text)
|
|
38
|
+
},
|
|
39
|
+
json(json: any) {
|
|
40
|
+
res.end(JSON.stringify(json))
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
await handler(runtimeReq, runtimeReply)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
listen(port, hostname) {
|
|
49
|
+
return new Promise((resolve) =>
|
|
50
|
+
server.listen(port, hostname, resolve)
|
|
51
|
+
)
|
|
52
|
+
},
|
|
53
|
+
close() {
|
|
54
|
+
return new Promise((resolve, reject) =>
|
|
55
|
+
server.close(err => err ? reject(err) : resolve())
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {RuntimeAdapterInterface, RuntimeReplyInterface, RuntimeRequestInterface} from '@/types'
|
|
2
|
+
|
|
3
|
+
export const webRuntime: RuntimeAdapterInterface = {
|
|
4
|
+
createServer(handler) {
|
|
5
|
+
async function fetching(request: Request, handler: (req: RuntimeRequestInterface, reply: RuntimeReplyInterface) => Promise<void>): Promise<Response> {
|
|
6
|
+
let responseBody: any
|
|
7
|
+
let statusCode = 200
|
|
8
|
+
const headers = new Headers()
|
|
9
|
+
|
|
10
|
+
const runtimeReq: RuntimeRequestInterface = {
|
|
11
|
+
method: request.method,
|
|
12
|
+
url: request.url,
|
|
13
|
+
headers: request.headers,
|
|
14
|
+
body: request.body as any
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const runtimeReply: RuntimeReplyInterface = {
|
|
18
|
+
status(code) {
|
|
19
|
+
statusCode = code
|
|
20
|
+
},
|
|
21
|
+
header(name, value) {
|
|
22
|
+
headers.set(name, value)
|
|
23
|
+
},
|
|
24
|
+
send(body) {
|
|
25
|
+
responseBody = body
|
|
26
|
+
},
|
|
27
|
+
text(text: string | Buffer) {
|
|
28
|
+
responseBody = text
|
|
29
|
+
},
|
|
30
|
+
json(json: any) {
|
|
31
|
+
responseBody = JSON.stringify(json)
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
await handler(runtimeReq, runtimeReply)
|
|
36
|
+
|
|
37
|
+
return new Response(
|
|
38
|
+
typeof responseBody === 'object' && !(responseBody instanceof Uint8Array)
|
|
39
|
+
? JSON.stringify(responseBody)
|
|
40
|
+
: responseBody,
|
|
41
|
+
{status: statusCode, headers}
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
async listen() {
|
|
47
|
+
console.warn('Web runtime does not support listening')
|
|
48
|
+
},
|
|
49
|
+
async close() {
|
|
50
|
+
console.warn('Web runtime does not support closing')
|
|
51
|
+
},
|
|
52
|
+
async handle(request: Request) {
|
|
53
|
+
return fetching(request, handler)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// import fs from "fs";
|
|
2
|
+
// import path from "path";
|
|
3
|
+
// import tsconfig from "../../../tsconfig.json";
|
|
4
|
+
//
|
|
5
|
+
// /**
|
|
6
|
+
// * Resolves the provided pathname to its corresponding alias path based on the configured TypeScript paths and output directories.
|
|
7
|
+
// *
|
|
8
|
+
// * @param {string} pathname - The input path to resolve as per the alias configurations in the TypeScript configuration.
|
|
9
|
+
// * @return {string | null} - The resolved alias path if it exists, or null if no matching alias is found.
|
|
10
|
+
// */
|
|
11
|
+
// export function aliasPath(pathname: string): string | null {
|
|
12
|
+
//
|
|
13
|
+
// const paths = (tsconfig.compilerOptions as any)?.paths ?? {};
|
|
14
|
+
// const prefix = (process.env.RAITON_NATURAL_MODE) ? "" : (tsconfig.compilerOptions?.outDir ?? "dist");
|
|
15
|
+
// // pathname = pathname.replace(/^@\/?/, prefix ? prefix + "/" : "");
|
|
16
|
+
//
|
|
17
|
+
// const baseUrl = (tsconfig.compilerOptions as any)?.baseUrl ?? ".";
|
|
18
|
+
//
|
|
19
|
+
// for (const [aliasPattern, resolvedPaths] of Object.entries(paths)) {
|
|
20
|
+
// const aliasKey = aliasPattern.replace("/*", "");
|
|
21
|
+
// const aliasValue = path.join(prefix, (resolvedPaths as string[])[0]?.replace("/*", ""));
|
|
22
|
+
//
|
|
23
|
+
// if (pathname.startsWith(aliasKey)) {
|
|
24
|
+
// const relativePath = pathname.replace(aliasKey, aliasValue);
|
|
25
|
+
// const fullPath = path.resolve(baseUrl, relativePath);
|
|
26
|
+
// const extensions = [".ts", ".js"];
|
|
27
|
+
//
|
|
28
|
+
// for (const ext of extensions)
|
|
29
|
+
// if (fs.existsSync(fullPath + ext))
|
|
30
|
+
// return fullPath + ext;
|
|
31
|
+
//
|
|
32
|
+
// if (fs.existsSync(path.join(fullPath, "index.ts")))
|
|
33
|
+
// return path.join(fullPath, "index.ts");
|
|
34
|
+
//
|
|
35
|
+
// if (fs.existsSync(path.join(fullPath, "index.js")))
|
|
36
|
+
// return path.join(fullPath, "index.js");
|
|
37
|
+
//
|
|
38
|
+
// if (fs.existsSync(path.join(fullPath, "index.mjs")))
|
|
39
|
+
// return path.join(fullPath, "index.mjs");
|
|
40
|
+
//
|
|
41
|
+
// if (fs.existsSync(path.join(fullPath, "index.cjs")))
|
|
42
|
+
// return path.join(fullPath, "index.cjs");
|
|
43
|
+
//
|
|
44
|
+
// return fullPath;
|
|
45
|
+
// }
|
|
46
|
+
// }
|
|
47
|
+
//
|
|
48
|
+
// return null;
|
|
49
|
+
// }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function isControllerArtifact(filename: string) {
|
|
2
|
+
return isArtifact(filename, 'controller')
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export function isServiceArtifact(filename: string) {
|
|
7
|
+
return isArtifact(filename, 'service')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function isArtifact(filename: string, artifact: string) {
|
|
11
|
+
return [
|
|
12
|
+
filename.endsWith(`.${artifact}.ts`),
|
|
13
|
+
filename.endsWith(`.${artifact}.js`),
|
|
14
|
+
filename.endsWith(`.${artifact}.mjs`),
|
|
15
|
+
filename.endsWith(`.${artifact}.cjs`),
|
|
16
|
+
].some(Boolean)
|
|
17
|
+
}
|
|
18
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {LBadge, Logger} from "@protorians/logger";
|
|
2
|
+
|
|
3
|
+
export async function retryCallable(
|
|
4
|
+
label: string,
|
|
5
|
+
callback: () => Promise<void>,
|
|
6
|
+
onFail?: (e: any) => void,
|
|
7
|
+
trying: number = 0,
|
|
8
|
+
limit: number = 7,
|
|
9
|
+
) {
|
|
10
|
+
try {
|
|
11
|
+
Logger.info(
|
|
12
|
+
LBadge.debug(label || 'Running'),
|
|
13
|
+
LBadge.info(trying),
|
|
14
|
+
LBadge.log(limit),
|
|
15
|
+
)
|
|
16
|
+
await callback()
|
|
17
|
+
} catch (e) {
|
|
18
|
+
Logger.info(
|
|
19
|
+
LBadge.debug('Trying'),
|
|
20
|
+
LBadge.info(trying),
|
|
21
|
+
LBadge.log(limit),
|
|
22
|
+
)
|
|
23
|
+
if (trying < limit)
|
|
24
|
+
setTimeout(() => retryCallable(label, callback, onFail, trying + 1, limit), 1000);
|
|
25
|
+
else onFail?.(e)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
|
|
3
|
+
export function tryParseJson<T>(obj: any): T | null {
|
|
4
|
+
try {
|
|
5
|
+
return JSON.parse(obj);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export class JsonUtil {
|
|
13
|
+
static trying = tryParseJson;
|
|
14
|
+
static parse = JSON.parse;
|
|
15
|
+
static stringify = JSON.stringify;
|
|
16
|
+
|
|
17
|
+
static import(pathname: string) {
|
|
18
|
+
const json = fs.readFileSync(pathname, "utf-8");
|
|
19
|
+
return JSON.parse(json);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
export function getDirname(importMetaUrl: string): string {
|
|
5
|
+
return path.dirname(fileURLToPath(importMetaUrl));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function getFilename(importMetaUrl: string): string {
|
|
9
|
+
return fileURLToPath(importMetaUrl);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getPackageRoot(importMetaUrl: string): string {
|
|
13
|
+
const dirname = getDirname(importMetaUrl);
|
|
14
|
+
// On remonte jusqu'à trouver un package.json ou on remonte d'un niveau si on est dans source/bin ou build/bin
|
|
15
|
+
if (dirname.endsWith('bin')) {
|
|
16
|
+
return path.join(dirname, '..');
|
|
17
|
+
}
|
|
18
|
+
return dirname;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {IGenericValueType} from "../../types";
|
|
2
|
+
|
|
3
|
+
export function getType(value: any): IGenericValueType {
|
|
4
|
+
if (typeof value === "string") return "string";
|
|
5
|
+
if (typeof value === "boolean") return "boolean";
|
|
6
|
+
if (typeof value === "bigint") return "bigInt";
|
|
7
|
+
if (typeof value === "number") {
|
|
8
|
+
if (Number.isInteger(value)) return "int";
|
|
9
|
+
return "float";
|
|
10
|
+
}
|
|
11
|
+
return (typeof value) as any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function stabilizeJson<T>(json: string | T | null) {
|
|
15
|
+
if (!json) return {} as T;
|
|
16
|
+
|
|
17
|
+
switch (typeof json) {
|
|
18
|
+
case 'string':
|
|
19
|
+
return JSON.parse(json);
|
|
20
|
+
case 'object':
|
|
21
|
+
return json as T;
|
|
22
|
+
default:
|
|
23
|
+
throw new Error('Invalid JSON format');
|
|
24
|
+
}
|
|
25
|
+
}
|