raiton 6.8.9-beta.25 → 6.10.0-beta.28
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 +44 -0
- package/README.md +46 -1
- package/benchmarks/README.md +16 -0
- package/benchmarks/latest.json +172 -0
- package/benchmarks/latest.md +66 -0
- package/build/bin/index.mjs +33550 -21725
- package/build/types/bin/bootstrapper.d.ts +2 -0
- package/build/types/bin/cli-output.d.ts +46 -0
- package/build/types/bin/cli-tools.d.ts +13 -0
- package/build/types/bin/cli.d.ts +3 -0
- package/build/types/bin/commands.registry.d.ts +4 -0
- package/build/types/bin/constants.d.ts +3 -0
- package/build/types/bin/file-utils.d.ts +21 -0
- package/build/types/bin/index.d.ts +2 -0
- package/build/types/bin/name-utils.d.ts +4 -0
- package/build/types/bin/project-utils.d.ts +12 -0
- package/build/types/commands/artifact.command.d.ts +7 -0
- package/build/types/commands/build.command.d.ts +8 -0
- package/build/types/commands/client.command.d.ts +7 -0
- package/build/types/commands/contract.command.d.ts +8 -0
- package/build/types/commands/develop.command.d.ts +9 -0
- package/build/types/commands/docs.command.d.ts +8 -0
- package/build/types/commands/doctor.command.d.ts +9 -0
- package/build/types/commands/generate.command.d.ts +7 -0
- package/build/types/commands/inspect.command.d.ts +7 -0
- package/build/types/commands/mcp.command.d.ts +11 -0
- package/build/types/commands/new.command.d.ts +7 -0
- package/build/types/commands/openapi.command.d.ts +7 -0
- package/build/types/commands/routes.command.d.ts +7 -0
- package/build/types/commands/start.command.d.ts +9 -0
- package/build/types/commands/why.command.d.ts +7 -0
- package/build/types/contracts/decorators.d.ts +41 -0
- package/build/types/contracts/errors.d.ts +42 -0
- package/build/types/contracts/index.d.ts +4 -0
- package/build/types/contracts/schema.d.ts +70 -0
- package/build/types/contracts/typebox.d.ts +81 -0
- package/build/types/core/application.d.ts +37 -0
- package/build/types/core/artifacts/artifact.d.ts +3 -0
- package/build/types/core/artifacts/index.d.ts +1 -0
- package/build/types/core/artifacts/runner.d.ts +1 -0
- package/build/types/core/builder.d.ts +42 -0
- package/build/types/core/bytes.util.d.ts +3 -0
- package/build/types/core/command.d.ts +13 -0
- package/build/types/core/commands.d.ts +10 -0
- package/build/types/core/config/config.d.ts +27 -0
- package/build/types/core/config/define.d.ts +8 -0
- package/build/types/core/config/index.d.ts +3 -0
- package/build/types/core/config/schema.d.ts +24 -0
- package/build/types/core/context.d.ts +11 -0
- package/build/types/core/controller/builder.d.ts +26 -0
- package/build/types/core/controller/compiler.d.ts +2 -0
- package/build/types/core/controller/index.d.ts +4 -0
- package/build/types/core/controller/metadata.d.ts +3 -0
- package/build/types/core/controller/tracker.d.ts +9 -0
- package/build/types/core/directories.d.ts +10 -0
- package/build/types/core/guards.d.ts +11 -0
- package/build/types/core/helpers/index.d.ts +1 -0
- package/build/types/core/helpers/raiton.d.ts +1 -0
- package/build/types/core/hooks.d.ts +14 -0
- package/build/types/core/index.d.ts +17 -0
- package/build/types/core/injection/index.d.ts +1 -0
- package/build/types/core/injection/injection.d.ts +37 -0
- package/build/types/core/mcp/builder.d.ts +2 -0
- package/build/types/core/mcp/index.d.ts +3 -0
- package/build/types/core/mcp/metadata.d.ts +9 -0
- package/build/types/core/mcp/tracker.d.ts +9 -0
- package/build/types/core/middleware/compose.d.ts +8 -0
- package/build/types/core/middleware/index.d.ts +2 -0
- package/build/types/core/middleware/pipeline.d.ts +12 -0
- package/build/types/core/plugins/index.d.ts +2 -0
- package/build/types/core/plugins/plugin.d.ts +2 -0
- package/build/types/core/plugins/scope.d.ts +15 -0
- package/build/types/core/process.util.d.ts +1 -0
- package/build/types/core/raiton.d.ts +15 -0
- package/build/types/core/router/handler.d.ts +2 -0
- package/build/types/core/router/handler.utils.d.ts +37 -0
- package/build/types/core/router/index.d.ts +4 -0
- package/build/types/core/router/matcher.d.ts +50 -0
- package/build/types/core/router/route.d.ts +52 -0
- package/build/types/core/router/router.d.ts +23 -0
- package/build/types/core/scheduler/builder.d.ts +2 -0
- package/build/types/core/scheduler/cron.d.ts +32 -0
- package/build/types/core/scheduler/duration.d.ts +7 -0
- package/build/types/core/scheduler/index.d.ts +6 -0
- package/build/types/core/scheduler/manager.d.ts +47 -0
- package/build/types/core/scheduler/metadata.d.ts +8 -0
- package/build/types/core/scheduler/queue/backend.d.ts +42 -0
- package/build/types/core/scheduler/queue/index.d.ts +3 -0
- package/build/types/core/scheduler/queue/rabbitmq.backend.d.ts +37 -0
- package/build/types/core/scheduler/queue/redis.backend.d.ts +38 -0
- package/build/types/core/server.d.ts +9 -0
- package/build/types/core/socket/builder.d.ts +1 -0
- package/build/types/core/socket/index.d.ts +2 -0
- package/build/types/core/socket/metadata.d.ts +14 -0
- package/build/types/core/thread.d.ts +21 -0
- package/build/types/framework/artifacts.d.ts +20 -0
- package/build/types/framework/cache/cache.d.ts +84 -0
- package/build/types/framework/cache/cache.decorator.d.ts +21 -0
- package/build/types/framework/cache/etag.d.ts +62 -0
- package/build/types/framework/cache/index.d.ts +4 -0
- package/build/types/framework/cache/types.d.ts +89 -0
- package/build/types/framework/constants/decorators.constant.d.ts +28 -0
- package/build/types/framework/constants/index.d.ts +2 -0
- package/build/types/framework/constants/microservices.constant.d.ts +3 -0
- package/build/types/framework/controllers.d.ts +2 -0
- package/build/types/framework/data-transfer-object.d.ts +5 -0
- package/build/types/framework/decorators/access-guard.decorator.d.ts +1 -0
- package/build/types/framework/decorators/api-response.decorator.d.ts +66 -0
- package/build/types/framework/decorators/api.decorator.d.ts +160 -0
- package/build/types/framework/decorators/controllable.decorator.d.ts +3 -0
- package/build/types/framework/decorators/csrf-guard.decorator.d.ts +2 -0
- package/build/types/framework/decorators/csrf-token.decorator.d.ts +1 -0
- package/build/types/framework/decorators/guard.decorator.d.ts +2 -0
- package/build/types/framework/decorators/health-check.decorator.d.ts +17 -0
- package/build/types/framework/decorators/index.d.ts +15 -0
- package/build/types/framework/decorators/injection.decorator.d.ts +5 -0
- package/build/types/framework/decorators/mcp.decorator.d.ts +68 -0
- package/build/types/framework/decorators/middleware.decorator.d.ts +3 -0
- package/build/types/framework/decorators/parametrable.decorator.d.ts +9 -0
- package/build/types/framework/decorators/routable.decorator.d.ts +12 -0
- package/build/types/framework/decorators/route-interaction.decorator.d.ts +81 -0
- package/build/types/framework/decorators/scheduler.decorator.d.ts +54 -0
- package/build/types/framework/decorators/socket.decorator.d.ts +5 -0
- package/build/types/framework/encryption.d.ts +25 -0
- package/build/types/framework/enums/csrf.enum.d.ts +4 -0
- package/build/types/framework/enums/encrypted.enum.d.ts +20 -0
- package/build/types/framework/enums/event.message.enum.d.ts +4 -0
- package/build/types/framework/enums/http-method.enum.d.ts +10 -0
- package/build/types/framework/enums/http-parameters.enum.d.ts +11 -0
- package/build/types/framework/enums/http-status.enum.d.ts +64 -0
- package/build/types/framework/enums/index.d.ts +9 -0
- package/build/types/framework/enums/runtime.enum.d.ts +5 -0
- package/build/types/framework/enums/scheduler.enum.d.ts +21 -0
- package/build/types/framework/enums/timestamp.enum.d.ts +6 -0
- package/build/types/framework/env.d.ts +3 -0
- package/build/types/framework/errors/catalog.d.ts +42 -0
- package/build/types/framework/exceptions/http-exception.d.ts +18 -0
- package/build/types/framework/exceptions/index.d.ts +2 -0
- package/build/types/framework/exceptions/throwable.d.ts +76 -0
- package/build/types/framework/health-check.d.ts +42 -0
- package/build/types/framework/index.d.ts +20 -0
- package/build/types/framework/mcp/audit.d.ts +12 -0
- package/build/types/framework/mcp/conformance.d.ts +31 -0
- package/build/types/framework/mcp/handler.d.ts +11 -0
- package/build/types/framework/mcp/index.d.ts +5 -0
- package/build/types/framework/mcp/protocol.d.ts +17 -0
- package/build/types/framework/mcp/rate-limit.d.ts +10 -0
- package/build/types/framework/mcp/stdio.d.ts +40 -0
- package/build/types/framework/mcp/streamable-http.d.ts +17 -0
- package/build/types/framework/observability/index.d.ts +6 -0
- package/build/types/framework/observability/metrics.d.ts +23 -0
- package/build/types/framework/observability/plugin.d.ts +20 -0
- package/build/types/framework/observability/readiness.d.ts +9 -0
- package/build/types/framework/observability/request.d.ts +7 -0
- package/build/types/framework/observability/shutdown.d.ts +21 -0
- package/build/types/framework/observability/trace.d.ts +96 -0
- package/build/types/framework/parameter-bag.d.ts +14 -0
- package/build/types/framework/plugins/body-parser.plugin.d.ts +3 -0
- package/build/types/framework/plugins/dev.plugin.d.ts +12 -0
- package/build/types/framework/plugins/index.d.ts +5 -0
- package/build/types/framework/plugins/mcp.plugin.d.ts +15 -0
- package/build/types/framework/plugins/openapi.plugin.d.ts +58 -0
- package/build/types/framework/plugins/security/body-limit.d.ts +1 -0
- package/build/types/framework/plugins/security/cors.d.ts +10 -0
- package/build/types/framework/plugins/security/csrf.d.ts +2 -0
- package/build/types/framework/plugins/security/headers.d.ts +1 -0
- package/build/types/framework/plugins/security/index.d.ts +13 -0
- package/build/types/framework/plugins/security/method-guard.d.ts +1 -0
- package/build/types/framework/plugins/security/rate-limit.d.ts +5 -0
- package/build/types/framework/repositories.d.ts +5 -0
- package/build/types/framework/responses/error.d.ts +13 -0
- package/build/types/framework/responses/helpers.d.ts +7 -0
- package/build/types/framework/responses/http-throwable.d.ts +14 -0
- package/build/types/framework/responses/http.d.ts +13 -0
- package/build/types/framework/responses/index.d.ts +4 -0
- package/build/types/framework/runtime/bun/server.d.ts +2 -0
- package/build/types/framework/runtime/deno/server.d.ts +2 -0
- package/build/types/framework/runtime/index.d.ts +17 -0
- package/build/types/framework/runtime/node/reply.d.ts +12 -0
- package/build/types/framework/runtime/node/request.d.ts +33 -0
- package/build/types/framework/runtime/node/server.d.ts +2 -0
- package/build/types/framework/runtime/web/server.d.ts +1 -0
- package/build/types/framework/services.d.ts +5 -0
- package/build/types/framework/utilities/alias-path.util.d.ts +1 -0
- package/build/types/framework/utilities/artifact.util.d.ts +7 -0
- package/build/types/framework/utilities/callable.util.d.ts +1 -0
- package/build/types/framework/utilities/cookie.util.d.ts +1 -0
- package/build/types/framework/utilities/csrf.util.d.ts +26 -0
- package/build/types/framework/utilities/https.util.d.ts +49 -0
- package/build/types/framework/utilities/index.d.ts +12 -0
- package/build/types/framework/utilities/ip.util.d.ts +15 -0
- package/build/types/framework/utilities/json.util.d.ts +10 -0
- package/build/types/framework/utilities/openapi.utils.d.ts +7 -0
- package/build/types/framework/utilities/openapi.utils.impl.d.ts +18 -0
- package/build/types/framework/utilities/path.util.d.ts +3 -0
- package/build/types/framework/utilities/route-suggestion.util.d.ts +10 -0
- package/build/types/framework/utilities/url.util.d.ts +1 -0
- package/build/types/framework/utilities/utilities.util.d.ts +3 -0
- package/build/types/framework/utilities/validation.util.d.ts +8 -0
- package/build/types/framework/view-model.d.ts +4 -0
- package/build/types/generators/artifact.templates.d.ts +7 -0
- package/build/types/generators/index.d.ts +2 -0
- package/build/types/generators/project.templates.d.ts +21 -0
- package/build/types/manifest/client.d.ts +12 -0
- package/build/types/manifest/contract.d.ts +25 -0
- package/build/types/manifest/index.d.ts +5 -0
- package/build/types/manifest/introspect.d.ts +18 -0
- package/build/types/manifest/manifest.d.ts +18 -0
- package/build/types/manifest/schema.d.ts +177 -0
- package/build/types/requirements.d.ts +1 -0
- package/build/types/types/access-guards.d.ts +4 -0
- package/build/types/types/application.d.ts +32 -0
- package/build/types/types/artifact.d.ts +8 -0
- package/build/types/types/builder.d.ts +37 -0
- package/build/types/types/config.d.ts +62 -0
- package/build/types/types/controller.d.ts +27 -0
- package/build/types/types/contruct.d.ts +1 -0
- package/build/types/types/core.d.ts +11 -0
- package/build/types/types/csrf.d.ts +33 -0
- package/build/types/types/directory.d.ts +6 -0
- package/build/types/types/encryption.d.ts +14 -0
- package/build/types/types/generic.d.ts +2 -0
- package/build/types/types/guard.d.ts +9 -0
- package/build/types/types/http-responses.d.ts +7 -0
- package/build/types/types/index.d.ts +27 -0
- package/build/types/types/injection.d.ts +11 -0
- package/build/types/types/lifecycle.d.ts +9 -0
- package/build/types/types/mcp.d.ts +148 -0
- package/build/types/types/middleware.d.ts +12 -0
- package/build/types/types/parseable.d.ts +3 -0
- package/build/types/types/plugin.d.ts +6 -0
- package/build/types/types/raiton.d.ts +13 -0
- package/build/types/types/responses.d.ts +20 -0
- package/build/types/types/router.d.ts +13 -0
- package/build/types/types/runtime.d.ts +48 -0
- package/build/types/types/scheduler.d.ts +140 -0
- package/build/types/types/scheme.d.ts +125 -0
- package/build/types/types/server.d.ts +10 -0
- package/build/types/types/socket.d.ts +11 -0
- package/build/types/types/thread.d.ts +25 -0
- package/build/types/types/utilities.d.ts +4 -0
- package/build/types/types/values.d.ts +2 -0
- package/docs/AGENTS.md +55 -0
- package/docs/CLAUDE.md +55 -0
- package/docs/README.md +5 -0
- package/docs/contributors/cli/README.md +17 -3
- package/docs/contributors/cli/commands.md +28 -17
- package/docs/contributors/framework/plugins/openapi.md +12 -3
- package/docs/generated/cli/commands.md +26 -0
- package/docs/generated/config-schema.json +150 -0
- package/docs/generated/manifest-schema.json +236 -0
- package/docs/generated/manifest.json +101 -0
- package/docs/llms-full.txt +1271 -0
- package/docs/llms.txt +46 -0
- package/docs/user-guide/README.md +18 -12
- package/docs/user-guide/cli.md +21 -0
- package/docs/user-guide/config.md +14 -0
- package/docs/user-guide/contracts.md +67 -0
- package/docs/user-guide/en/README.md +83 -0
- package/docs/user-guide/getting-started.md +13 -1
- package/docs/user-guide/mcp.md +45 -2
- package/docs/user-guide/observability.md +74 -0
- package/docs/user-guide/openapi/plugin.md +10 -0
- package/docs/user-guide/recipes/README.md +32 -0
- package/docs/user-guide/recipes/contracts.md +52 -0
- package/docs/user-guide/recipes/doctor.md +16 -0
- package/docs/user-guide/recipes/generate.md +28 -0
- package/docs/user-guide/recipes/manifest.md +17 -0
- package/docs/user-guide/recipes/mcp-stdio.md +35 -0
- package/docs/user-guide/recipes/new-project.md +34 -0
- package/docs/user-guide/recipes/observability.md +17 -0
- package/package.json +40 -7
- package/scripts/bench.ts +586 -0
- package/scripts/postinstall.mjs +15 -0
- package/source/bin/cli-output.ts +139 -0
- package/source/bin/commands.registry.ts +23 -3
- package/source/bin/file-utils.ts +95 -0
- package/source/bin/name-utils.ts +26 -0
- package/source/bin/project-utils.ts +78 -0
- package/source/commands/artifact.command.ts +30 -15
- package/source/commands/client.command.ts +64 -0
- package/source/commands/contract.command.ts +104 -0
- package/source/commands/docs.command.ts +263 -0
- package/source/commands/doctor.command.ts +226 -0
- package/source/commands/generate.command.ts +58 -0
- package/source/commands/inspect.command.ts +108 -0
- package/source/commands/mcp.command.ts +258 -0
- package/source/commands/new.command.ts +135 -0
- package/source/commands/openapi.command.ts +95 -0
- package/source/commands/routes.command.ts +39 -0
- package/source/commands/why.command.ts +61 -0
- package/source/contracts/decorators.ts +151 -0
- package/source/contracts/errors.ts +76 -0
- package/source/contracts/index.ts +4 -0
- package/source/contracts/schema.ts +377 -0
- package/source/contracts/typebox.ts +193 -0
- package/source/core/application.ts +215 -73
- package/source/core/builder.ts +6 -2
- package/source/core/config/config.ts +144 -26
- package/source/core/config/define.ts +35 -8
- package/source/core/config/index.ts +2 -1
- package/source/core/config/schema.ts +263 -0
- package/source/core/controller/builder.ts +38 -13
- package/source/core/controller/compiler.ts +14 -7
- package/source/core/controller/metadata.ts +1 -1
- package/source/core/hooks.ts +13 -1
- package/source/core/injection/injection.ts +47 -9
- package/source/core/mcp/builder.ts +13 -2
- package/source/core/mcp/metadata.ts +2 -1
- package/source/core/middleware/compose.ts +48 -0
- package/source/core/middleware/pipeline.ts +69 -46
- package/source/core/raiton.ts +8 -0
- package/source/core/router/handler.ts +91 -31
- package/source/core/router/handler.utils.ts +107 -51
- package/source/core/router/matcher.ts +195 -24
- package/source/core/router/route.ts +100 -31
- package/source/core/router/router.ts +27 -2
- package/source/core/scheduler/metadata.ts +1 -1
- package/source/core/socket/metadata.ts +1 -1
- package/source/core/thread.ts +37 -2
- package/source/framework/artifacts.ts +47 -15
- package/source/framework/cache/cache.ts +48 -3
- package/source/framework/constants/decorators.constant.ts +5 -0
- package/source/framework/data-transfer-object.ts +4 -3
- package/source/framework/decorators/controllable.decorator.ts +3 -3
- package/source/framework/decorators/csrf-guard.decorator.ts +3 -2
- package/source/framework/decorators/csrf-token.decorator.ts +1 -1
- package/source/framework/decorators/guard.decorator.ts +3 -2
- package/source/framework/decorators/health-check.decorator.ts +1 -1
- package/source/framework/decorators/mcp.decorator.ts +38 -7
- package/source/framework/decorators/middleware.decorator.ts +2 -2
- package/source/framework/decorators/parametrable.decorator.ts +2 -1
- package/source/framework/decorators/routable.decorator.ts +3 -3
- package/source/framework/decorators/route-interaction.decorator.ts +2 -2
- package/source/framework/decorators/scheduler.decorator.ts +3 -3
- package/source/framework/decorators/socket.decorator.ts +3 -3
- package/source/framework/encryption.ts +46 -7
- package/source/framework/errors/catalog.ts +159 -0
- package/source/framework/exceptions/http-exception.ts +1 -1
- package/source/framework/health-check.ts +18 -0
- package/source/framework/index.ts +2 -0
- package/source/framework/mcp/audit.ts +57 -0
- package/source/framework/mcp/conformance.ts +195 -0
- package/source/framework/mcp/handler.ts +131 -9
- package/source/framework/mcp/index.ts +6 -1
- package/source/framework/mcp/protocol.ts +6 -0
- package/source/framework/mcp/rate-limit.ts +33 -0
- package/source/framework/mcp/stdio.ts +150 -0
- package/source/framework/mcp/streamable-http.ts +36 -5
- package/source/framework/observability/index.ts +6 -0
- package/source/framework/observability/metrics.ts +162 -0
- package/source/framework/observability/plugin.ts +151 -0
- package/source/framework/observability/readiness.ts +22 -0
- package/source/framework/observability/request.ts +31 -0
- package/source/framework/observability/shutdown.ts +68 -0
- package/source/framework/observability/trace.ts +241 -0
- package/source/framework/plugins/body-parser.plugin.ts +88 -85
- package/source/framework/plugins/dev.plugin.ts +227 -0
- package/source/framework/plugins/index.ts +2 -1
- package/source/framework/plugins/mcp.plugin.ts +14 -3
- package/source/framework/plugins/openapi.plugin.ts +56 -13
- package/source/framework/responses/helpers.ts +4 -4
- package/source/framework/responses/http-throwable.ts +1 -1
- package/source/framework/runtime/bun/server.ts +2 -1
- package/source/framework/runtime/deno/server.ts +2 -1
- package/source/framework/runtime/index.ts +45 -13
- package/source/framework/runtime/node/request.ts +59 -13
- package/source/framework/utilities/index.ts +3 -1
- package/source/framework/utilities/openapi.utils.impl.ts +705 -0
- package/source/framework/utilities/openapi.utils.ts +6 -636
- package/source/framework/utilities/route-suggestion.util.ts +59 -0
- package/source/framework/utilities/validation.util.ts +20 -0
- package/source/generators/artifact.templates.ts +230 -0
- package/source/generators/index.ts +2 -0
- package/source/generators/project.templates.ts +392 -0
- package/source/manifest/client.ts +299 -0
- package/source/manifest/contract.ts +138 -0
- package/source/manifest/index.ts +5 -0
- package/source/manifest/introspect.ts +52 -0
- package/source/manifest/manifest.ts +341 -0
- package/source/manifest/schema.ts +149 -0
- package/source/types/builder.ts +5 -0
- package/source/types/config.ts +64 -2
- package/source/types/mcp.ts +63 -1
- package/tsconfig.build.json +13 -0
- package/source/commands/grafts.command.ts +0 -27
- package/tests/artifact-resolution.test.ts +0 -60
|
@@ -0,0 +1,1271 @@
|
|
|
1
|
+
# Raiton
|
|
2
|
+
|
|
3
|
+
> Modular TypeScript backend framework with dependency injection, plugins, schema-first contracts, MCP (HTTP + stdio), observability and typed CLI tooling.
|
|
4
|
+
|
|
5
|
+
## Start
|
|
6
|
+
|
|
7
|
+
- [Getting started](user-guide/getting-started.md): create, run and test a project in under five minutes.
|
|
8
|
+
- [Configuration](user-guide/config.md): `raiton.config.ts` is typed and validated before the port opens.
|
|
9
|
+
- [Contracts](user-guide/recipes/contracts.md): one schema feeds validation, TypeScript types, OpenAPI and the generated client.
|
|
10
|
+
- [MCP](user-guide/mcp.md): expose tools over HTTP and stdio with safety annotations.
|
|
11
|
+
- [Observability](user-guide/observability.md): correlation ids, Prometheus metrics, OTLP traces and graceful shutdown.
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
- `raiton new <name>`: Create a project from a template
|
|
16
|
+
- `raiton generate <type> <name>`: Generate controller, service, repository, dto, mcp-tool, test or resource
|
|
17
|
+
- `raiton routes`: List mounted routes
|
|
18
|
+
- `raiton inspect`: Emit the versioned project manifest
|
|
19
|
+
- `raiton why <method> <path>`: Explain which file registered a route
|
|
20
|
+
- `raiton doctor`: Diagnose runtime, configuration and prerequisites
|
|
21
|
+
- `raiton openapi export`: Export the OpenAPI document
|
|
22
|
+
- `raiton client`: Generate a typed client
|
|
23
|
+
- `raiton contract check`: Detect breaking contract changes
|
|
24
|
+
- `raiton contract snapshot`: Write a contract baseline
|
|
25
|
+
- `raiton mcp list`: List MCP servers
|
|
26
|
+
- `raiton mcp inspect <server>`: Inspect MCP schemas and safety annotations
|
|
27
|
+
- `raiton mcp test <server>.<tool>`: Call an MCP tool
|
|
28
|
+
- `raiton mcp serve [server]`: Serve an MCP server over stdio
|
|
29
|
+
- `raiton mcp conformance [server]`: Run the HTTP + stdio conformance suite
|
|
30
|
+
- `raiton docs agents`: Generate llms.txt, llms-full.txt, AGENTS.md and CLAUDE.md
|
|
31
|
+
- `raiton artifact --dump`: Inspect detected artifacts
|
|
32
|
+
- `raiton dev`: Run the application with HMR
|
|
33
|
+
- `raiton build`: Build the application
|
|
34
|
+
- `raiton start`: Run the application in production
|
|
35
|
+
|
|
36
|
+
## Project inventory
|
|
37
|
+
|
|
38
|
+
- Framework: raiton 6.8.9-beta.25
|
|
39
|
+
- Runtime: unknown
|
|
40
|
+
- Manifest schema: 1.0.0
|
|
41
|
+
- Routes: 0
|
|
42
|
+
- MCP servers: 0
|
|
43
|
+
|
|
44
|
+
## Routes
|
|
45
|
+
|
|
46
|
+
No route is currently mounted.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<!-- user-guide/getting-started.md -->
|
|
50
|
+
|
|
51
|
+
# Démarrage rapide
|
|
52
|
+
|
|
53
|
+
> **Navigation :** [← user-guide](README.md) | [architecture →](architecture.md)
|
|
54
|
+
|
|
55
|
+
Le point d’entrée attendu est `source/main.ts`.
|
|
56
|
+
Le projet peut aussi définir `raiton.config.ts` à la racine pour décrire le `rootDir`, la version et les options globales.
|
|
57
|
+
|
|
58
|
+
La séparation attendue est la suivante :
|
|
59
|
+
- `raiton.config.ts` décrit le projet
|
|
60
|
+
- `source/main.ts` crée et démarre le serveur
|
|
61
|
+
- `source/modules/`, `source/controllers/`, `source/services/` et `source/repositories/` contiennent la logique applicative
|
|
62
|
+
|
|
63
|
+
## Créer un projet en une commande
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
bun raiton new my-api --template api --runtime bun --yes
|
|
67
|
+
cd my-api
|
|
68
|
+
bun raiton dev
|
|
69
|
+
bun test
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`--template` accepte `api`, `minimal` et `mcp-agent`. `--dry-run` affiche le
|
|
73
|
+
plan sans écrire, `--offline` et `--no-install` désactivent l'installation.
|
|
74
|
+
|
|
75
|
+
## Installer dans un projet existant
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
bun add raiton reflect-metadata
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Bootstrap
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import "reflect-metadata"
|
|
85
|
+
import { ThreadInterface } from "raiton/types"
|
|
86
|
+
import { Application } from "raiton/core"
|
|
87
|
+
import { RuntimeType } from "raiton/framework"
|
|
88
|
+
|
|
89
|
+
export default async (thread: ThreadInterface) => {
|
|
90
|
+
const app = new Application({
|
|
91
|
+
port: 5711,
|
|
92
|
+
prefix: "/api"
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
return await thread.setup({
|
|
96
|
+
application: app,
|
|
97
|
+
runtime: RuntimeType.Bun
|
|
98
|
+
}).run()
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Lancer
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
bun raiton dev
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Configuration projet
|
|
109
|
+
|
|
110
|
+
Exemple de fichier `raiton.config.ts` :
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
export default {
|
|
114
|
+
rootDir: "./source",
|
|
115
|
+
version: "0.10.0",
|
|
116
|
+
port: 5711,
|
|
117
|
+
pathname: "/",
|
|
118
|
+
artifacts: {
|
|
119
|
+
types: ["controller", "socket", "service"]
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Dans ce schéma, Raiton charge les fichiers depuis `source/` et le bootstrapper reste dans `source/main.ts`.
|
|
125
|
+
|
|
126
|
+
## Vérifier
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
curl http://localhost:5711/api/users
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
[← user-guide](README.md) | [architecture →](architecture.md)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
<!-- user-guide/architecture.md -->
|
|
138
|
+
|
|
139
|
+
# Structure recommandée
|
|
140
|
+
|
|
141
|
+
> **Navigation :** [← getting-started](getting-started.md) | [api →](api/README.md)
|
|
142
|
+
|
|
143
|
+
Une structure simple et lisible fonctionne bien pour la plupart des projets.
|
|
144
|
+
Le guide recommande une logique par domaine, avec une couche API et des services dédiés.
|
|
145
|
+
|
|
146
|
+
```text
|
|
147
|
+
source/
|
|
148
|
+
├── controllers/
|
|
149
|
+
├── services/
|
|
150
|
+
├── repositories/
|
|
151
|
+
├── middleware/
|
|
152
|
+
├── plugins/
|
|
153
|
+
├── dto/
|
|
154
|
+
├── models/
|
|
155
|
+
├── modules/
|
|
156
|
+
├── core/
|
|
157
|
+
└── main.ts
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Le principe est de séparer :
|
|
161
|
+
- la couche HTTP
|
|
162
|
+
- la logique métier
|
|
163
|
+
- l’accès aux données
|
|
164
|
+
- les règles transverses
|
|
165
|
+
|
|
166
|
+
## Exemple concret
|
|
167
|
+
|
|
168
|
+
Pour une API de gestion de tâches, une structure lisible peut ressembler à ceci :
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
source/
|
|
172
|
+
├── controllers/
|
|
173
|
+
│ └── tasks.controller.ts
|
|
174
|
+
├── services/
|
|
175
|
+
│ └── tasks.service.ts
|
|
176
|
+
├── repositories/
|
|
177
|
+
│ └── tasks.repository.ts
|
|
178
|
+
├── dto/
|
|
179
|
+
│ ├── create-task.dto.ts
|
|
180
|
+
│ └── update-task.dto.ts
|
|
181
|
+
├── middleware/
|
|
182
|
+
│ └── auth.middleware.ts
|
|
183
|
+
├── plugins/
|
|
184
|
+
│ └── openapi.plugin.ts
|
|
185
|
+
├── modules/
|
|
186
|
+
│ └── tasks/
|
|
187
|
+
│ ├── application/
|
|
188
|
+
│ ├── domain/
|
|
189
|
+
│ └── presentation/
|
|
190
|
+
└── main.ts
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Règle simple :
|
|
194
|
+
- `controller` reçoit la requête et retourne la réponse
|
|
195
|
+
- `service` applique la règle métier
|
|
196
|
+
- `repository` parle à la base de données
|
|
197
|
+
- `dto` définit la forme attendue des données
|
|
198
|
+
- `modules/` regroupe un domaine complet quand l’application grossit
|
|
199
|
+
|
|
200
|
+
## Modèle de module
|
|
201
|
+
|
|
202
|
+
Un module peut être organisé comme suit :
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
modules/
|
|
206
|
+
└── users/
|
|
207
|
+
├── application/
|
|
208
|
+
│ └── service/
|
|
209
|
+
├── domain/
|
|
210
|
+
│ └── entities/
|
|
211
|
+
├── presentation/
|
|
212
|
+
│ ├── components/
|
|
213
|
+
│ └── views/
|
|
214
|
+
└── index.ts
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Cette organisation réduit les fichiers dispersés et facilite la lecture par domaine.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
[← getting-started](getting-started.md) | [api →](api/README.md)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
<!-- user-guide/cli.md -->
|
|
225
|
+
|
|
226
|
+
# CLI et workflow
|
|
227
|
+
|
|
228
|
+
> **Navigation :** [← plugins](plugins.md) | [best-practices →](best-practices.md)
|
|
229
|
+
|
|
230
|
+
Le CLI couvre le cycle standard de développement d’une application Raiton.
|
|
231
|
+
|
|
232
|
+
## Pourquoi utilisé
|
|
233
|
+
|
|
234
|
+
- lancer rapidement un serveur en local
|
|
235
|
+
- vérifier le comportement pendant l’implémentation
|
|
236
|
+
- produire une version compilée pour la livraison ou le déploiement
|
|
237
|
+
|
|
238
|
+
Raiton fonctionne sur les trois runtimes majeurs : **Bun**, **Node.js** et **Deno**.
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Bun — exécution TypeScript native (aucune compilation requise)
|
|
242
|
+
bun raiton dev
|
|
243
|
+
bun raiton build
|
|
244
|
+
bun raiton start
|
|
245
|
+
|
|
246
|
+
# Node.js — le CLI est fourni sous forme de bundle JS (build/bin/index.mjs)
|
|
247
|
+
node build/bin/index.mjs dev
|
|
248
|
+
node build/bin/index.mjs start
|
|
249
|
+
|
|
250
|
+
# Deno — exécution TypeScript native, tâches déclarées dans deno.json
|
|
251
|
+
deno task dev
|
|
252
|
+
deno task build
|
|
253
|
+
deno task start
|
|
254
|
+
deno task compile # génère un binaire autonome (build/bin/raiton)
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Commandes principales
|
|
258
|
+
|
|
259
|
+
- `dev` lance le projet avec hot reloading (HMR)
|
|
260
|
+
- `build` génère un artefact exécutable
|
|
261
|
+
- `start` démarre l’application compilée (sans HMR)
|
|
262
|
+
|
|
263
|
+
## Onboarding, contrats et diagnostic
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
bun raiton new my-api --template api --runtime bun --yes
|
|
267
|
+
bun raiton generate resource users
|
|
268
|
+
bun raiton routes --json
|
|
269
|
+
bun raiton inspect --json
|
|
270
|
+
bun raiton why GET /api/users/:id
|
|
271
|
+
bun raiton doctor --json
|
|
272
|
+
bun raiton openapi export --out openapi.json
|
|
273
|
+
bun raiton client --out ./sdk
|
|
274
|
+
bun raiton contract check --baseline openapi.baseline.json
|
|
275
|
+
bun raiton mcp list --json
|
|
276
|
+
bun raiton mcp conformance --json
|
|
277
|
+
bun raiton docs agents
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Toutes les commandes machine écrivent un document JSON unique sur `stdout`
|
|
281
|
+
(logs sur `stderr`) et utilisent des codes de sortie stables : `0` succès,
|
|
282
|
+
`1` usage, `2` prérequis manquant, `3` conflit de fichiers, `4` diagnostic.
|
|
283
|
+
|
|
284
|
+
## Commandes utiles
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
bun raiton --help
|
|
288
|
+
bun raiton --version
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Quand vous faites évoluer l’application, gardez l’ordre suivant :
|
|
292
|
+
- modifier le code
|
|
293
|
+
- lancer `bun raiton dev`
|
|
294
|
+
- vérifier le comportement
|
|
295
|
+
- lancer `bun raiton build` avant livraison
|
|
296
|
+
|
|
297
|
+
## Mode dev vs mode prod
|
|
298
|
+
|
|
299
|
+
Le mode dev utilise le système de HMR embarqué : le builder observe le
|
|
300
|
+
répertoire source et recompile les artefacts (contrôleurs, services,
|
|
301
|
+
middlewares, sockets, hooks, MCP) sans redémarrer le processus.
|
|
302
|
+
|
|
303
|
+
Le mode `start` démarre l’application sans HMR :
|
|
304
|
+
- sur **Bun** et **Deno**, le bootstrapper TypeScript est importé directement
|
|
305
|
+
- sur **Node.js**, l’application est compilée (esbuild) vers `.raiton/server/main.mjs`
|
|
306
|
+
puis exécutée
|
|
307
|
+
|
|
308
|
+
## Runtimes
|
|
309
|
+
|
|
310
|
+
| Runtime | Exécution TS native | Dev (HMR) | Prod (bundle) |
|
|
311
|
+
| --- | --- | --- | --- |
|
|
312
|
+
| Bun | Oui | `bun raiton dev` | `bun raiton start` |
|
|
313
|
+
| Node.js | Non (bundle JS requis) | `node build/bin/index.mjs dev` | `node build/bin/index.mjs start` |
|
|
314
|
+
| Deno | Oui | `deno task dev` | `deno task start` / `deno task compile` |
|
|
315
|
+
|
|
316
|
+
## Avantages
|
|
317
|
+
|
|
318
|
+
- flux simple et prévisible
|
|
319
|
+
- adapté au développement quotidien
|
|
320
|
+
- garde la différence claire entre exécution locale et artefact compilé
|
|
321
|
+
|
|
322
|
+
## Inconvénients
|
|
323
|
+
|
|
324
|
+
- demande de bien distinguer `dev` et `start`
|
|
325
|
+
- le build ajoute une étape supplémentaire avant livraison
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
[← plugins](plugins.md) | [best-practices →](best-practices.md)
|
|
330
|
+
|
|
331
|
+
<!-- user-guide/config.md -->
|
|
332
|
+
|
|
333
|
+
# Configuration
|
|
334
|
+
|
|
335
|
+
> **Navigation :** [← getting-started](getting-started.md) | [architecture →](architecture.md)
|
|
336
|
+
|
|
337
|
+
Le fichier `raiton.config.ts` décrit la racine du projet et quelques options globales.
|
|
338
|
+
|
|
339
|
+
## Pourquoi utilisé
|
|
340
|
+
|
|
341
|
+
- définir le `rootDir`
|
|
342
|
+
- centraliser les valeurs de base de l’application
|
|
343
|
+
- garder le bootstrap propre
|
|
344
|
+
|
|
345
|
+
## Exemple
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
export default {
|
|
349
|
+
rootDir: "./source",
|
|
350
|
+
version: "0.10.0",
|
|
351
|
+
port: 5711,
|
|
352
|
+
hostname: "0.0.0.0",
|
|
353
|
+
protocole: "http",
|
|
354
|
+
pathname: "/",
|
|
355
|
+
artifacts: {
|
|
356
|
+
types: ["controller", "socket", "service"]
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## Chargement et validation
|
|
362
|
+
|
|
363
|
+
Ordre de chargement documenté :
|
|
364
|
+
|
|
365
|
+
```text
|
|
366
|
+
raiton.config.ts → .mts → .cts → .js → .mjs → .cjs → .json
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
La configuration est validée **avant l’ouverture du port**. Une valeur
|
|
370
|
+
invalide produit des erreurs par champ et empêche l’écoute. Le schéma JSON
|
|
371
|
+
publié est disponible dans `docs/generated/config-schema.json` ou via
|
|
372
|
+
`raiton inspect --config-schema`.
|
|
373
|
+
|
|
374
|
+
## Comment l’utiliser
|
|
375
|
+
|
|
376
|
+
- placez le fichier à la racine du projet
|
|
377
|
+
- gardez `source/main.ts` comme point d’entrée applicatif
|
|
378
|
+
- ajustez `rootDir` si votre code source n’est pas dans `source/`
|
|
379
|
+
- utilisez `defineConfigSync` pour le typage et la validation à la définition
|
|
380
|
+
|
|
381
|
+
## Avantages
|
|
382
|
+
|
|
383
|
+
- configuration lisible
|
|
384
|
+
- séparation claire entre code et runtime
|
|
385
|
+
|
|
386
|
+
## Inconvénients
|
|
387
|
+
|
|
388
|
+
- le projet doit suivre une convention de chargement
|
|
389
|
+
- les options doivent rester cohérentes avec le bootstrap
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
[← getting-started](getting-started.md) | [architecture →](architecture.md)
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
<!-- user-guide/api/routes.md -->
|
|
397
|
+
|
|
398
|
+
# Routes d’API
|
|
399
|
+
|
|
400
|
+
> **Navigation :** [← README](README.md) | [responses →](responses.md)
|
|
401
|
+
|
|
402
|
+
Raiton décrit les routes dans des classes de contrôleur avec `@Controllable()` et les décorateurs HTTP.
|
|
403
|
+
|
|
404
|
+
## Pourquoi utilisé
|
|
405
|
+
|
|
406
|
+
- regrouper les routes par domaine métier
|
|
407
|
+
- garder le code proche de l’intention HTTP
|
|
408
|
+
- simplifier le câblage du serveur
|
|
409
|
+
|
|
410
|
+
## Comment l’utiliser
|
|
411
|
+
|
|
412
|
+
- créez un contrôleur avec `@Controllable("/users")`
|
|
413
|
+
- ajoutez `@Get()`, `@Post()`, `@Put()`, `@Patch()` ou `@Delete()`
|
|
414
|
+
- utilisez les décorateurs de paramètres pour extraire les données d’entrée
|
|
415
|
+
|
|
416
|
+
## Exemple
|
|
417
|
+
|
|
418
|
+
```typescript
|
|
419
|
+
import { Controllable, Get, Post, Param, Body } from "raiton/framework"
|
|
420
|
+
|
|
421
|
+
@Controllable("/users")
|
|
422
|
+
export class UsersController {
|
|
423
|
+
@Get("/")
|
|
424
|
+
list() {
|
|
425
|
+
return []
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
@Get("/:id")
|
|
429
|
+
getOne(@Param("id") id: string) {
|
|
430
|
+
return { id }
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
@Post("/")
|
|
434
|
+
create(@Body() payload: { name: string }) {
|
|
435
|
+
return payload
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## Avantages
|
|
441
|
+
|
|
442
|
+
- lisible
|
|
443
|
+
- aligné sur le vocabulaire HTTP
|
|
444
|
+
- facile à faire évoluer
|
|
445
|
+
|
|
446
|
+
## Inconvénients
|
|
447
|
+
|
|
448
|
+
- nécessite une convention de structure
|
|
449
|
+
- peut devenir volumineux si un contrôleur gère trop d’actions
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
[← README](README.md) | [responses →](responses.md)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
<!-- user-guide/responses.md -->
|
|
457
|
+
|
|
458
|
+
# Réponses
|
|
459
|
+
|
|
460
|
+
> **Navigation :** [← middleware](middleware.md) | [plugins →](plugins.md)
|
|
461
|
+
|
|
462
|
+
Raiton peut renvoyer une réponse de plusieurs façons :
|
|
463
|
+
- un objet simple
|
|
464
|
+
- une exception HTTP
|
|
465
|
+
- une réponse structurée
|
|
466
|
+
|
|
467
|
+
## Réponse simple
|
|
468
|
+
|
|
469
|
+
Le cas le plus courant est de retourner un objet.
|
|
470
|
+
|
|
471
|
+
```typescript
|
|
472
|
+
@Get("/users")
|
|
473
|
+
list() {
|
|
474
|
+
return {
|
|
475
|
+
ok: true,
|
|
476
|
+
service: "raiton-api"
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
Pourquoi utilisé
|
|
482
|
+
- c’est la forme la plus simple
|
|
483
|
+
- le framework sérialise automatiquement en JSON
|
|
484
|
+
|
|
485
|
+
Avantages
|
|
486
|
+
- rapide à écrire
|
|
487
|
+
- lisible
|
|
488
|
+
|
|
489
|
+
Inconvénients
|
|
490
|
+
- peu de contrôle sur le format final si l’on ne standardise pas la réponse
|
|
491
|
+
|
|
492
|
+
## Réponse structurée
|
|
493
|
+
|
|
494
|
+
Pour des APIs cohérentes, il est utile de standardiser la forme de réponse.
|
|
495
|
+
|
|
496
|
+
```typescript
|
|
497
|
+
return {
|
|
498
|
+
statusCode: 200,
|
|
499
|
+
error: false,
|
|
500
|
+
message: "OK",
|
|
501
|
+
data: {
|
|
502
|
+
id: "1",
|
|
503
|
+
name: "John Doe"
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
Pourquoi utilisé
|
|
509
|
+
- uniformiser les réponses
|
|
510
|
+
- faciliter l’intégration côté frontend
|
|
511
|
+
|
|
512
|
+
Avantages
|
|
513
|
+
- format prévisible
|
|
514
|
+
- plus simple à consommer
|
|
515
|
+
|
|
516
|
+
Inconvénients
|
|
517
|
+
- un peu plus verbeux
|
|
518
|
+
|
|
519
|
+
## Erreurs HTTP
|
|
520
|
+
|
|
521
|
+
Lorsque la ressource n’existe pas ou qu’une règle métier échoue, renvoyez une erreur explicite.
|
|
522
|
+
|
|
523
|
+
```typescript
|
|
524
|
+
import { HttpException, HttpStatus } from "raiton/framework"
|
|
525
|
+
|
|
526
|
+
@Get("/:id")
|
|
527
|
+
getOne(@Param("id") id: string) {
|
|
528
|
+
if (id !== "1") {
|
|
529
|
+
throw new HttpException("Utilisateur introuvable", HttpStatus.NOT_FOUND)
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
return { id: "1", name: "John Doe" }
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
## Réponses textuelles ou binaires
|
|
537
|
+
|
|
538
|
+
Quand il faut renvoyer autre chose que du JSON, utilisez le `reply` brut.
|
|
539
|
+
|
|
540
|
+
```typescript
|
|
541
|
+
@Get("/export")
|
|
542
|
+
export(@Reply() reply: any) {
|
|
543
|
+
reply.type("text/csv")
|
|
544
|
+
return reply.send("id,name\n1,John Doe")
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
## Conseils
|
|
549
|
+
|
|
550
|
+
- garder un format de réponse stable
|
|
551
|
+
- utiliser les exceptions pour les erreurs métier
|
|
552
|
+
- réserver `reply` aux cas où le JSON ne suffit pas
|
|
553
|
+
|
|
554
|
+
---
|
|
555
|
+
|
|
556
|
+
[← middleware](middleware.md) | [plugins →](plugins.md)
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
<!-- user-guide/injection.md -->
|
|
560
|
+
|
|
561
|
+
# Injection et services
|
|
562
|
+
|
|
563
|
+
> **Navigation :** [← api](api/README.md) | [plugins →](plugins.md)
|
|
564
|
+
|
|
565
|
+
Le schéma recommandé est de laisser le contrôleur orchestrer la requête, puis de déléguer la logique métier au service.
|
|
566
|
+
|
|
567
|
+
Cette couche sert souvent à encapsuler les appels vers une base de données, une API externe ou un système de stockage.
|
|
568
|
+
|
|
569
|
+
```typescript
|
|
570
|
+
import { Injectable } from "raiton/framework"
|
|
571
|
+
|
|
572
|
+
@Injectable()
|
|
573
|
+
export class UserService {
|
|
574
|
+
private readonly users = [
|
|
575
|
+
{ id: "1", name: "John Doe" },
|
|
576
|
+
{ id: "2", name: "Jane Doe" }
|
|
577
|
+
]
|
|
578
|
+
|
|
579
|
+
findAll() {
|
|
580
|
+
return this.users
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
findById(id: string) {
|
|
584
|
+
return this.users.find((user) => user.id === id) ?? null
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
create(name: string) {
|
|
588
|
+
const user = { id: crypto.randomUUID(), name }
|
|
589
|
+
this.users.push(user)
|
|
590
|
+
return user
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
```typescript
|
|
596
|
+
import { Controllable, Get, Inject, Param } from "raiton/framework"
|
|
597
|
+
import { UserService } from "../services/user.service"
|
|
598
|
+
|
|
599
|
+
@Controllable("/users")
|
|
600
|
+
export class UserController {
|
|
601
|
+
constructor(
|
|
602
|
+
@Inject(UserService) private readonly userService: UserService
|
|
603
|
+
) {}
|
|
604
|
+
|
|
605
|
+
@Get("/")
|
|
606
|
+
list() {
|
|
607
|
+
return this.userService.findAll()
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
@Get("/:id")
|
|
611
|
+
getOne(@Param("id") id: string) {
|
|
612
|
+
const user = this.userService.findById(id)
|
|
613
|
+
return user ?? { error: true, statusCode: 404, message: "Utilisateur introuvable" }
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
Utilisez cette approche pour séparer clairement :
|
|
619
|
+
- les contrôleurs
|
|
620
|
+
- la logique métier
|
|
621
|
+
- la persistance
|
|
622
|
+
|
|
623
|
+
## Pourquoi c’est utile
|
|
624
|
+
|
|
625
|
+
- les tests ciblent le service sans démarrer tout le serveur
|
|
626
|
+
- les contrôleurs restent minces
|
|
627
|
+
- les règles métier deviennent réutilisables
|
|
628
|
+
|
|
629
|
+
## Convention de nommage
|
|
630
|
+
|
|
631
|
+
Une convention fréquente consiste à nommer les services par domaine et par rôle :
|
|
632
|
+
- `UsersService`
|
|
633
|
+
- `UsersRepository`
|
|
634
|
+
- `UsersController`
|
|
635
|
+
|
|
636
|
+
Cette convention aide à identifier rapidement le domaine et le rôle du service.
|
|
637
|
+
|
|
638
|
+
---
|
|
639
|
+
|
|
640
|
+
[← api](api/README.md) | [plugins →](plugins.md)
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
<!-- user-guide/contracts.md -->
|
|
644
|
+
|
|
645
|
+
# Contrats schema-first
|
|
646
|
+
|
|
647
|
+
Une seule définition alimente la validation runtime, les types TypeScript, OpenAPI et le client généré.
|
|
648
|
+
|
|
649
|
+
## Déclarer un contrat
|
|
650
|
+
|
|
651
|
+
```ts
|
|
652
|
+
import {t} from "raiton/contracts"
|
|
653
|
+
|
|
654
|
+
export const CreateUser = t.object({
|
|
655
|
+
email: t.string().email(),
|
|
656
|
+
name: t.string().min(2),
|
|
657
|
+
age: t.integer().min(0).optional(),
|
|
658
|
+
})
|
|
659
|
+
|
|
660
|
+
export type CreateUser = t.infer<typeof CreateUser>
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
## Brancher une route
|
|
664
|
+
|
|
665
|
+
```ts
|
|
666
|
+
import {Body, Controllable, Post} from "raiton/framework"
|
|
667
|
+
import {Input, Output, t} from "raiton/contracts"
|
|
668
|
+
|
|
669
|
+
const User = t.object({id: t.string(), name: t.string()})
|
|
670
|
+
|
|
671
|
+
@Controllable("/users")
|
|
672
|
+
export class UsersController {
|
|
673
|
+
@Post("/")
|
|
674
|
+
@Input(CreateUser)
|
|
675
|
+
@Output(User)
|
|
676
|
+
create(@Body() input: CreateUser) {
|
|
677
|
+
return this.users.create(input)
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
## Erreur stable
|
|
683
|
+
|
|
684
|
+
Une entrée invalide n'exécute jamais le handler :
|
|
685
|
+
|
|
686
|
+
```json
|
|
687
|
+
{
|
|
688
|
+
"error": true,
|
|
689
|
+
"code": "VALIDATION_ERROR",
|
|
690
|
+
"message": "Invalid request",
|
|
691
|
+
"statusCode": 400,
|
|
692
|
+
"details": [{"path": "email", "code": "invalid_format", "message": "Expected string to match 'email' format"}],
|
|
693
|
+
"docsUrl": "https://github.com/protorians/raiton/blob/main/docs/user-guide/recipes/contracts.md"
|
|
694
|
+
}
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
## Validation de sortie
|
|
698
|
+
|
|
699
|
+
- `validation.responses: "auto"` (défaut) : active en développement, désactive en production.
|
|
700
|
+
- `true` / `false` : force le comportement.
|
|
701
|
+
- En développement, un écart retourne `OUTPUT_VALIDATION_ERROR` avec la route et le champ fautif.
|
|
702
|
+
- En production, aucun coût n'est ajouté.
|
|
703
|
+
|
|
704
|
+
## OpenAPI et client
|
|
705
|
+
|
|
706
|
+
```bash
|
|
707
|
+
raiton openapi export --out openapi.json
|
|
708
|
+
raiton client --out ./sdk
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
Les schémas d'entrée/sortie OpenAPI proviennent des mêmes `@Input`/`@Output`. Le client généré n'utilise jamais `any` : les schémas inconnus deviennent `unknown`.
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
<!-- user-guide/mcp.md -->
|
|
715
|
+
|
|
716
|
+
# MCP (Model Context Protocol)
|
|
717
|
+
|
|
718
|
+
> **Navigation :** [← sockets](sockets.md) | [scheduler →](scheduler.md)
|
|
719
|
+
|
|
720
|
+
Raiton permet de créer un serveur **MCP (Model Context Protocol)** facilement, avec des décorateurs, et de le faire coexister avec le serveur HTTP et les sockets sur le même processus et le même port.
|
|
721
|
+
|
|
722
|
+
## De quoi s’agit-il
|
|
723
|
+
|
|
724
|
+
MCP est un protocole qui expose des **outils (tools)**, des **prompts** et des **ressources (resources)** à des clients IA (assistants, agents, IDE…). Raiton implémente le transport **Streamable HTTP** : un simple endpoint qui accepte des requêtes JSON-RPC `POST`, identique au reste de l’API.
|
|
725
|
+
|
|
726
|
+
## Pourquoi utilisé
|
|
727
|
+
|
|
728
|
+
- exposer une logique applicative existante à des assistants IA
|
|
729
|
+
- réutiliser les services et l’injection de dépendances existants
|
|
730
|
+
- cohabiter avec les contrôleurs HTTP et les sockets sans serveur séparé
|
|
731
|
+
- bénéficier du HMR, des artifacts et d’OpenAPI, comme pour le reste du framework
|
|
732
|
+
|
|
733
|
+
## Comment l’utiliser
|
|
734
|
+
|
|
735
|
+
1. Créez un fichier artifact `*.mcp.ts` (reconnu automatiquement)
|
|
736
|
+
2. Déclarez une classe avec `@McpServer()`
|
|
737
|
+
3. Ajoutez des méthodes avec `@McpTool()`, `@McpPrompt()`, `@McpResource()` ou `@McpResourceTemplate()`
|
|
738
|
+
4. Déclarez les paramètres avec `@McpArg()`
|
|
739
|
+
5. Le chemin `path` du serveur devient automatiquement accessible en `POST`
|
|
740
|
+
|
|
741
|
+
## Exemple
|
|
742
|
+
|
|
743
|
+
```typescript
|
|
744
|
+
import { McpServer, McpTool, McpPrompt, McpResource, McpResourceTemplate, McpArg } from "raiton/framework"
|
|
745
|
+
|
|
746
|
+
@McpServer({ name: "math", version: "1.0.0", path: "/mcp" })
|
|
747
|
+
export class MathServer {
|
|
748
|
+
@McpTool({ name: "add", description: "Additionne deux nombres" })
|
|
749
|
+
add(
|
|
750
|
+
@McpArg("a", "Premier opérande", Number) a: number,
|
|
751
|
+
@McpArg("b", "Second opérande", Number) b: number,
|
|
752
|
+
) {
|
|
753
|
+
return a + b
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
@McpPrompt({ name: "resume", description: "Résume un texte" })
|
|
757
|
+
resume(@McpArg("text", "Le texte à résumer", String) text: string) {
|
|
758
|
+
return `Résume le texte suivant :\n\n${text}`
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
@McpResource({ uri: "config://app", name: "Configuration", mimeType: "application/json" })
|
|
762
|
+
config() {
|
|
763
|
+
return { env: "production" }
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
@McpResourceTemplate({ uriTemplate: "user://{id}", name: "Utilisateur par id" })
|
|
767
|
+
user({ id }: any) {
|
|
768
|
+
return { id, name: `User-${id}` }
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
Aucun enregistrement supplémentaire n’est nécessaire : le scanner détecte `*.mcp.ts`, compile la classe, enregistre le serveur dans le registre MCP et ajoute automatiquement les routes `POST /mcp` et `GET /mcp` sur l’application.
|
|
774
|
+
|
|
775
|
+
## Points d’extensibilité
|
|
776
|
+
|
|
777
|
+
### Enregistrement manuel
|
|
778
|
+
|
|
779
|
+
Vous pouvez aussi compiler et enregistrer un serveur MCP explicitement :
|
|
780
|
+
|
|
781
|
+
```typescript
|
|
782
|
+
import { compileMcp } from "raiton/core"
|
|
783
|
+
|
|
784
|
+
compileMcp(MathServer)
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
### Plugin MCP
|
|
788
|
+
|
|
789
|
+
Le plugin `mcpPlugin()` permet un montage explicite sur un chemin personnalisé et d’activer le endpoint `GET` :
|
|
790
|
+
|
|
791
|
+
```typescript
|
|
792
|
+
import { app } from "raiton"
|
|
793
|
+
|
|
794
|
+
app.register(mcpPlugin({ path: "/mcp", enableGet: true }))
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
> Les routes étant normalement auto-générées par la compilation, le plugin est surtout utile lorsque vous gérez vous-même l’enregistrement ou souhaitez un contrôle fin.
|
|
798
|
+
|
|
799
|
+
## Protocole
|
|
800
|
+
|
|
801
|
+
Le endpoint répond au protocole MCP sur JSON-RPC 2.0 :
|
|
802
|
+
|
|
803
|
+
- `initialize` — négociation de la version et des capacités
|
|
804
|
+
- `ping` — test de disponibilité
|
|
805
|
+
- `tools/list` / `tools/call`
|
|
806
|
+
- `prompts/list` / `prompts/get`
|
|
807
|
+
- `resources/list` / `resources/templates/list` / `resources/read`
|
|
808
|
+
- `logging/setLevel` / `notifications/initialized`
|
|
809
|
+
|
|
810
|
+
La version du protocole est vérifiée : une version non supportée renvoie `406`. Les réponses utilisent le header `mcp-session-id`.
|
|
811
|
+
|
|
812
|
+
## HMR
|
|
813
|
+
|
|
814
|
+
Les fichiers `*.mcp.ts` bénéficient du **hot reload** : une modification recharge le serveur MCP sans redémarrer le process, exactement comme les contrôleurs et les sockets.
|
|
815
|
+
|
|
816
|
+
## Transports HTTP et stdio
|
|
817
|
+
|
|
818
|
+
Le même registre d'outils est servi par :
|
|
819
|
+
|
|
820
|
+
- **Streamable HTTP** sur le chemin déclaré (`/mcp` par défaut) ;
|
|
821
|
+
- **stdio**, pour les clients qui lancent le serveur comme sous-processus :
|
|
822
|
+
|
|
823
|
+
```bash
|
|
824
|
+
raiton mcp serve math --stdio
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
Les deux transports passent la même suite de conformité :
|
|
828
|
+
|
|
829
|
+
```bash
|
|
830
|
+
raiton mcp conformance math --json
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
## Schémas et sûreté
|
|
834
|
+
|
|
835
|
+
```ts
|
|
836
|
+
@McpTool({
|
|
837
|
+
name: "refund",
|
|
838
|
+
description: "Rembourse une commande",
|
|
839
|
+
inputSchema: RefundInput,
|
|
840
|
+
outputSchema: RefundOutput,
|
|
841
|
+
scopes: ["payments:write"],
|
|
842
|
+
annotations: {readOnlyHint: false, destructiveHint: true, idempotentHint: false},
|
|
843
|
+
})
|
|
844
|
+
refund(@McpArg("orderId", "Identifiant", String) orderId: string) {
|
|
845
|
+
return this.payments.refund(orderId)
|
|
846
|
+
}
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
- `inputSchema` / `outputSchema` sont exposés à `tools/list`.
|
|
850
|
+
- Un outil `destructiveHint: true` est **masqué par défaut** ; il faut
|
|
851
|
+
`mcp.exposeDestructive: true` dans `raiton.config.ts` ou
|
|
852
|
+
`@McpServer({exposeDestructive: true})`.
|
|
853
|
+
- Les scopes sont vérifiés lorsqu'ils sont fournis (`x-mcp-scopes` en HTTP,
|
|
854
|
+
contexte du transport en stdio).
|
|
855
|
+
- Les appels sont audités (identifiant, outil, durée, acteur, résultat) et les
|
|
856
|
+
secrets sont expurgés.
|
|
857
|
+
- Une limite de débit par outil peut être configurée
|
|
858
|
+
(`mcp.rateLimitPerMinute`).
|
|
859
|
+
|
|
860
|
+
## OpenAPI
|
|
861
|
+
|
|
862
|
+
Les serveurs MCP sont documentés dans le contrat OpenAPI généré, avec une extension `x-mcp` listant outils, prompts et ressources.
|
|
863
|
+
|
|
864
|
+
## Avantages
|
|
865
|
+
|
|
866
|
+
- intégration native avec le serveur HTTP existant
|
|
867
|
+
- réutilise l’injection de dépendances
|
|
868
|
+
- HMR, artifacts et OpenAPI homogènes avec le reste du framework
|
|
869
|
+
- transport stdio pour les agents locaux
|
|
870
|
+
|
|
871
|
+
## Inconvénients
|
|
872
|
+
|
|
873
|
+
- les notifications serveur `GET` (SSE) restent basiques
|
|
874
|
+
- le protocole évolue vite, la liste des versions supportées doit être suivie
|
|
875
|
+
|
|
876
|
+
---
|
|
877
|
+
|
|
878
|
+
[← sockets](sockets.md) | [scheduler →](scheduler.md)
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
<!-- user-guide/observability.md -->
|
|
882
|
+
|
|
883
|
+
# Observabilité et exploitation
|
|
884
|
+
|
|
885
|
+
L'observabilité est opt-in. Désactivée, elle n'ajoute aucun travail sur le chemin chaud.
|
|
886
|
+
|
|
887
|
+
## Activer
|
|
888
|
+
|
|
889
|
+
```bash
|
|
890
|
+
RAITON_OBSERVABILITY=off|metrics|traces|all
|
|
891
|
+
RAITON_METRICS_PATH=/metrics
|
|
892
|
+
RAITON_OTEL_ENDPOINT=http://localhost:4318
|
|
893
|
+
RAITON_REQUEST_ID_HEADER=x-request-id
|
|
894
|
+
RAITON_SHUTDOWN_TIMEOUT_MS=10000
|
|
895
|
+
RAITON_ACCESS_LOG=1
|
|
896
|
+
```
|
|
897
|
+
|
|
898
|
+
`RAITON_ACCESS_LOG=1` ajoute une ligne par requête avec l'identifiant de
|
|
899
|
+
corrélation et celui de trace. Les logs d'erreur portent toujours
|
|
900
|
+
l'identifiant.
|
|
901
|
+
|
|
902
|
+
Ou dans `raiton.config.ts` :
|
|
903
|
+
|
|
904
|
+
```ts
|
|
905
|
+
export default {
|
|
906
|
+
observability: {mode: "all", metricsPath: "/metrics"},
|
|
907
|
+
shutdown: {timeoutMs: 10000},
|
|
908
|
+
}
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
## Corrélation
|
|
912
|
+
|
|
913
|
+
Chaque requête reçoit un identifiant :
|
|
914
|
+
|
|
915
|
+
- repris de `x-request-id` s'il est valide ;
|
|
916
|
+
- sinon généré ;
|
|
917
|
+
- présent dans la réponse, les logs et le contexte (`ctx.state.requestId`).
|
|
918
|
+
|
|
919
|
+
## Métriques
|
|
920
|
+
|
|
921
|
+
`GET /metrics` expose le format texte Prometheus :
|
|
922
|
+
|
|
923
|
+
- `http_requests_total{method,route,status}`
|
|
924
|
+
- `http_request_duration_seconds` (histogramme)
|
|
925
|
+
- `http_errors_total{method,route,status}`
|
|
926
|
+
|
|
927
|
+
Le chemin est relatif au préfixe de l'application.
|
|
928
|
+
|
|
929
|
+
## Traces
|
|
930
|
+
|
|
931
|
+
- Les spans entrants utilisent `traceparent` lorsqu'il est fourni.
|
|
932
|
+
- Les appels sortants doivent utiliser `tracedFetch` (exporté par `raiton/framework`) pour partager la trace.
|
|
933
|
+
- Export OTLP/HTTP JSON vers `RAITON_OTEL_ENDPOINT`.
|
|
934
|
+
|
|
935
|
+
## Erreurs
|
|
936
|
+
|
|
937
|
+
Toutes les erreurs HTTP publiques suivent le catalogue `code → statut → message → docsUrl`. En production, aucune pile d'appels n'est retournée.
|
|
938
|
+
|
|
939
|
+
## Arrêt gracieux
|
|
940
|
+
|
|
941
|
+
Sur `SIGINT`/`SIGTERM` :
|
|
942
|
+
|
|
943
|
+
1. readiness passe immédiatement à `false` (`/health` répond 503) ;
|
|
944
|
+
2. les nouvelles connexions sont refusées ;
|
|
945
|
+
3. les requêtes en cours sont drainées jusqu'à `shutdown.timeoutMs` ;
|
|
946
|
+
4. le processus sort en `0`.
|
|
947
|
+
|
|
948
|
+
## Budgets
|
|
949
|
+
|
|
950
|
+
Les budgets de la spec 001 restent la référence :
|
|
951
|
+
|
|
952
|
+
| Mode | Surcoût cible p50 |
|
|
953
|
+
|---|---|
|
|
954
|
+
| `off` | 0 mesurable |
|
|
955
|
+
| `metrics` | ≤ 5 % |
|
|
956
|
+
| `traces` | ≤ 10 % |
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
<!-- user-guide/decorators/README.md -->
|
|
960
|
+
|
|
961
|
+
# Décorateurs
|
|
962
|
+
|
|
963
|
+
> **Navigation :** [← api](../api/README.md) | [runtime →](../runtime.md)
|
|
964
|
+
|
|
965
|
+
Cette section regroupe les décorateurs que vous utilisez pour définir vos contrôleurs, routes, paramètres, injections, plugins et métadonnées OpenAPI.
|
|
966
|
+
|
|
967
|
+
## Fiches disponibles
|
|
968
|
+
|
|
969
|
+
- [controllable.md](controllable.md)
|
|
970
|
+
- [routes.md](routes.md)
|
|
971
|
+
- [parameters.md](parameters.md)
|
|
972
|
+
- [injection.md](injection.md)
|
|
973
|
+
- [middleware.md](middleware.md)
|
|
974
|
+
- [cache.md](cache.md)
|
|
975
|
+
- [socket.md](socket.md)
|
|
976
|
+
- [api-tags.md](api-tags.md)
|
|
977
|
+
- [api-operation.md](api-operation.md)
|
|
978
|
+
- [api-response.md](api-response.md)
|
|
979
|
+
- [api-body.md](api-body.md)
|
|
980
|
+
- [api-param.md](api-param.md)
|
|
981
|
+
- [api-property.md](api-property.md)
|
|
982
|
+
- [api-query.md](api-query.md)
|
|
983
|
+
- [route-interaction.md](route-interaction.md)
|
|
984
|
+
- [guard.md](guard.md)
|
|
985
|
+
- [health-check.md](health-check.md)
|
|
986
|
+
- [mcp.md](mcp.md)
|
|
987
|
+
- [scheduler.md](scheduler.md)
|
|
988
|
+
|
|
989
|
+
## Comment lire cette section
|
|
990
|
+
|
|
991
|
+
- commencez par `controllable.md` et `routes.md`
|
|
992
|
+
- utilisez ensuite `parameters.md`, `injection.md` et `middleware.md`
|
|
993
|
+
- documentez vos endpoints temps réel et IA avec `socket.md` et `mcp.md`
|
|
994
|
+
- planifiez des tâches avec `scheduler.md`
|
|
995
|
+
- qualifiez un endpoint de santé avec `health-check.md`
|
|
996
|
+
- terminez par les décorateurs OpenAPI si vous documentez votre API
|
|
997
|
+
|
|
998
|
+
---
|
|
999
|
+
|
|
1000
|
+
[← api](../api/README.md) | [runtime →](../runtime.md)
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
<!-- user-guide/recipes/README.md -->
|
|
1004
|
+
|
|
1005
|
+
# Recettes exécutables
|
|
1006
|
+
|
|
1007
|
+
Chaque fonctionnalité publique dispose d'une recette : objectif, fichier complet, commande, sortie attendue.
|
|
1008
|
+
Une recette qui ne s'exécute pas en CI est considérée comme cassée.
|
|
1009
|
+
|
|
1010
|
+
| Fonctionnalité | Recette | Commande |
|
|
1011
|
+
|---|---|---|
|
|
1012
|
+
| Création de projet | [new-project.md](new-project.md) | `raiton new demo --template api --yes` |
|
|
1013
|
+
| Génération d'artifacts | [generate.md](generate.md) | `raiton generate resource users` |
|
|
1014
|
+
| Contrats schema-first | [contracts.md](contracts.md) | `raiton contract check --baseline baseline.json` |
|
|
1015
|
+
| MCP HTTP + stdio | [mcp-stdio.md](mcp-stdio.md) | `raiton mcp conformance --json` |
|
|
1016
|
+
| Manifeste et découverte | [manifest.md](manifest.md) | `raiton inspect --json` |
|
|
1017
|
+
| Observabilité | [observability.md](observability.md) | `RAITON_OBSERVABILITY=all raiton dev` |
|
|
1018
|
+
| Diagnostic | [doctor.md](doctor.md) | `raiton doctor --json` |
|
|
1019
|
+
|
|
1020
|
+
## Couverture des décorateurs
|
|
1021
|
+
|
|
1022
|
+
| Décorateur | Documentation |
|
|
1023
|
+
|---|---|
|
|
1024
|
+
| `@Controllable` | [../decorators/controllable.md](../decorators/controllable.md) |
|
|
1025
|
+
| `@Get/@Post/@Put/@Patch/@Delete` | [../decorators/routes.md](../decorators/routes.md) |
|
|
1026
|
+
| `@Body/@Query/@Param/@Headers/@Cookie` | [../decorators/parameters.md](../decorators/parameters.md) |
|
|
1027
|
+
| `@Injectable/@Inject` | [../decorators/injection.md](../decorators/injection.md) |
|
|
1028
|
+
| `@Middleware` | [../decorators/middleware.md](../decorators/middleware.md) |
|
|
1029
|
+
| `@Guard` | [../decorators/guard.md](../decorators/guard.md) |
|
|
1030
|
+
| `@Cache` | [../decorators/cache.md](../decorators/cache.md) |
|
|
1031
|
+
| `@HealthCheck` | [../decorators/health-check.md](../decorators/health-check.md) |
|
|
1032
|
+
| `@McpServer/@McpTool/@McpArg` | [../decorators/mcp.md](../decorators/mcp.md) |
|
|
1033
|
+
| `@Scheduler` | [../decorators/scheduler.md](../decorators/scheduler.md) |
|
|
1034
|
+
| `@Socket` | [../decorators/socket.md](../decorators/socket.md) |
|
|
1035
|
+
| `@ApiOperation/@ApiResponse/@ApiProperty` | [../decorators/api-operation.md](../decorators/api-operation.md) |
|
|
1036
|
+
| `@Input/@Output` | [contracts.md](contracts.md) |
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
<!-- user-guide/en/README.md -->
|
|
1040
|
+
|
|
1041
|
+
# Raiton user guide (English)
|
|
1042
|
+
|
|
1043
|
+
This is the English reference for the same contract as the French guide.
|
|
1044
|
+
|
|
1045
|
+
## Start
|
|
1046
|
+
|
|
1047
|
+
```bash
|
|
1048
|
+
bun raiton new my-api --template api --runtime bun --yes
|
|
1049
|
+
cd my-api
|
|
1050
|
+
bun raiton dev
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
- `GET /api/health` — health check.
|
|
1054
|
+
- Example controller route under `/api/<project>`.
|
|
1055
|
+
- `bun test` — generated tests.
|
|
1056
|
+
|
|
1057
|
+
## Configuration
|
|
1058
|
+
|
|
1059
|
+
`raiton.config.ts` is typed and validated before the port opens. Invalid fields prevent listening and report each field.
|
|
1060
|
+
|
|
1061
|
+
```ts
|
|
1062
|
+
import {defineConfigSync} from "raiton/core"
|
|
1063
|
+
|
|
1064
|
+
export default defineConfigSync({
|
|
1065
|
+
rootDir: "./source",
|
|
1066
|
+
port: 5711,
|
|
1067
|
+
prefix: "/api",
|
|
1068
|
+
observability: {mode: "off"},
|
|
1069
|
+
validation: {responses: "auto"},
|
|
1070
|
+
})
|
|
1071
|
+
```
|
|
1072
|
+
|
|
1073
|
+
## Contracts
|
|
1074
|
+
|
|
1075
|
+
One schema feeds runtime validation, TypeScript types, OpenAPI and the generated client:
|
|
1076
|
+
|
|
1077
|
+
```ts
|
|
1078
|
+
import {t} from "raiton/contracts"
|
|
1079
|
+
|
|
1080
|
+
export const CreateUser = t.object({email: t.string().email()})
|
|
1081
|
+
export type CreateUser = t.infer<typeof CreateUser>
|
|
1082
|
+
```
|
|
1083
|
+
|
|
1084
|
+
Use `@Input(CreateUser)` / `@Output(User)`. Invalid input is rejected before the handler with a stable `VALIDATION_ERROR` payload.
|
|
1085
|
+
|
|
1086
|
+
## CLI
|
|
1087
|
+
|
|
1088
|
+
All diagnostic and generation commands support `--json`, stable exit codes and non-interactive operation.
|
|
1089
|
+
|
|
1090
|
+
```bash
|
|
1091
|
+
raiton routes --json
|
|
1092
|
+
raiton inspect --json
|
|
1093
|
+
raiton why GET /api/users/:id
|
|
1094
|
+
raiton doctor --json
|
|
1095
|
+
raiton openapi export --out openapi.json
|
|
1096
|
+
raiton client --out ./sdk
|
|
1097
|
+
raiton contract check --baseline openapi.baseline.json
|
|
1098
|
+
raiton mcp list --json
|
|
1099
|
+
raiton mcp conformance --json
|
|
1100
|
+
raiton docs agents
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
Exit codes: `0` success, `1` usage, `2` missing prerequisite, `3` file conflict, `4` diagnostic failure.
|
|
1104
|
+
|
|
1105
|
+
## MCP
|
|
1106
|
+
|
|
1107
|
+
```ts
|
|
1108
|
+
@McpServer({name: "math", path: "/mcp"})
|
|
1109
|
+
export class MathServer {
|
|
1110
|
+
@McpTool({name: "add", annotations: {readOnlyHint: true}})
|
|
1111
|
+
add(@McpArg("a", "First", Number) a: number, @McpArg("b", "Second", Number) b: number) {
|
|
1112
|
+
return {result: a + b}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
```
|
|
1116
|
+
|
|
1117
|
+
- HTTP and stdio transports share the same conformance suite.
|
|
1118
|
+
- Destructive tools are hidden unless `mcp.exposeDestructive` or the server option is explicit.
|
|
1119
|
+
- Tool calls are audited and secrets are redacted.
|
|
1120
|
+
|
|
1121
|
+
## Observability
|
|
1122
|
+
|
|
1123
|
+
See [observability](../observability.md) for correlation ids, Prometheus metrics, OTLP traces and graceful shutdown.
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
<!-- user-guide/best-practices.md -->
|
|
1127
|
+
|
|
1128
|
+
# Bonnes pratiques
|
|
1129
|
+
|
|
1130
|
+
> **Navigation :** [← cli](cli.md) | [↑ user-guide](README.md)
|
|
1131
|
+
|
|
1132
|
+
Dans un projet Raiton, gardez ces règles simples :
|
|
1133
|
+
|
|
1134
|
+
- importez `reflect-metadata` une seule fois au point d’entrée
|
|
1135
|
+
- gardez les contrôleurs fins
|
|
1136
|
+
- déplacez la logique métier dans des services
|
|
1137
|
+
- isolez l’accès aux données dans des repositories
|
|
1138
|
+
- préférez des routes stables et explicites
|
|
1139
|
+
- activez les plugins de sécurité dès que l’API est exposée publiquement
|
|
1140
|
+
- centralisez les conventions par domaine
|
|
1141
|
+
- utilisez une structure modulaire quand plusieurs fonctionnalités métier cohabitent
|
|
1142
|
+
- importez les interfaces et types avec `import type` (ou `import {type X}` en inline pour un mélange) quand ils ne servent qu’à la compilation : avec Bun et `emitDecoratorMetadata`, un import de valeur d’un symbole type-only lève `SyntaxError: Export named '…' not found` au démarrage — laissez les entités/classes runtime en import de valeur
|
|
1143
|
+
|
|
1144
|
+
## Exemple de découpage
|
|
1145
|
+
|
|
1146
|
+
- `UsersController` reçoit la requête HTTP
|
|
1147
|
+
- `UsersService` applique les règles métier
|
|
1148
|
+
- `UsersRepository` lit/écrit les données
|
|
1149
|
+
- `UsersDto` décrit les entrées attendues
|
|
1150
|
+
- `UsersMiddleware` gère les règles transverses
|
|
1151
|
+
- `UsersResponses` garde un format de sortie stable
|
|
1152
|
+
|
|
1153
|
+
Ce découpage garde l’application lisible quand le nombre de routes augmente.
|
|
1154
|
+
|
|
1155
|
+
## Ce qu’il faut éviter
|
|
1156
|
+
|
|
1157
|
+
- un `main.ts` qui contient toute la logique métier
|
|
1158
|
+
- des contrôleurs qui parlent directement à la base
|
|
1159
|
+
- des routes sans convention de nommage
|
|
1160
|
+
- une documentation API séparée du code
|
|
1161
|
+
|
|
1162
|
+
---
|
|
1163
|
+
|
|
1164
|
+
[← cli](cli.md) | [↑ user-guide](README.md)
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
## Generated manifest
|
|
1168
|
+
|
|
1169
|
+
```json
|
|
1170
|
+
{
|
|
1171
|
+
"schemaVersion": "1.0.0",
|
|
1172
|
+
"generatedAt": "generated",
|
|
1173
|
+
"framework": {
|
|
1174
|
+
"name": "raiton",
|
|
1175
|
+
"version": "6.8.9-beta.25"
|
|
1176
|
+
},
|
|
1177
|
+
"runtime": "unknown",
|
|
1178
|
+
"project": {
|
|
1179
|
+
"rootDir": ".",
|
|
1180
|
+
"entry": "main.ts"
|
|
1181
|
+
},
|
|
1182
|
+
"routes": [],
|
|
1183
|
+
"injection": {},
|
|
1184
|
+
"artifacts": [
|
|
1185
|
+
"controller",
|
|
1186
|
+
"mcp",
|
|
1187
|
+
"util"
|
|
1188
|
+
],
|
|
1189
|
+
"config": {
|
|
1190
|
+
"rootDir": "string",
|
|
1191
|
+
"version": "string",
|
|
1192
|
+
"observability": "object",
|
|
1193
|
+
"validation": "object",
|
|
1194
|
+
"shutdown": "object",
|
|
1195
|
+
"mcp": "object"
|
|
1196
|
+
},
|
|
1197
|
+
"env": [
|
|
1198
|
+
"API_KEY",
|
|
1199
|
+
"APPDATA",
|
|
1200
|
+
"ARM_VERSION",
|
|
1201
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
1202
|
+
"BENCH_ROUTES",
|
|
1203
|
+
"BOOK_LANG",
|
|
1204
|
+
"CI_BRANCH",
|
|
1205
|
+
"CLICOLOR_FORCE",
|
|
1206
|
+
"COLUMNS",
|
|
1207
|
+
"DATABASE_PASSWORD",
|
|
1208
|
+
"DEBUG",
|
|
1209
|
+
"DEPLOY_TOKEN",
|
|
1210
|
+
"DOTENV_CONFIG_DEBUG",
|
|
1211
|
+
"DOTENV_CONFIG_DOTENV_KEY",
|
|
1212
|
+
"DOTENV_CONFIG_ENCODING",
|
|
1213
|
+
"DOTENV_CONFIG_OVERRIDE",
|
|
1214
|
+
"DOTENV_CONFIG_PATH",
|
|
1215
|
+
"DOTENV_CONFIG_QUIET",
|
|
1216
|
+
"DOTENV_KEY",
|
|
1217
|
+
"EDITOR",
|
|
1218
|
+
"ELECTRON_RUN_AS_NODE",
|
|
1219
|
+
"ESBUILD_BINARY_PATH",
|
|
1220
|
+
"ESBUILD_MAX_BUFFER",
|
|
1221
|
+
"ESBUILD_WORKER_THREADS",
|
|
1222
|
+
"FOO",
|
|
1223
|
+
"FORCE_COLOR",
|
|
1224
|
+
"FORMAT_START",
|
|
1225
|
+
"GITHUB_REF_NAME",
|
|
1226
|
+
"GITHUB_TOKEN",
|
|
1227
|
+
"GRACEFUL_FS_PLATFORM",
|
|
1228
|
+
"HOME",
|
|
1229
|
+
"HOMEDRIVE",
|
|
1230
|
+
"HOMEPATH",
|
|
1231
|
+
"HOST",
|
|
1232
|
+
"IGNORE_TEST_WIN32",
|
|
1233
|
+
"LIBC",
|
|
1234
|
+
"LNAME",
|
|
1235
|
+
"LOGNAME",
|
|
1236
|
+
"NODE_COMPILE_CACHE",
|
|
1237
|
+
"NODE_DEBUG",
|
|
1238
|
+
"NODE_ENV",
|
|
1239
|
+
"NODE_TEST_WORKER_ID",
|
|
1240
|
+
"NODE_UNIQUE_ID",
|
|
1241
|
+
"NO_COLOR",
|
|
1242
|
+
"OSTYPE",
|
|
1243
|
+
"PATH",
|
|
1244
|
+
"PATHEXT",
|
|
1245
|
+
"PORT",
|
|
1246
|
+
"PREBUILDS_ONLY",
|
|
1247
|
+
"PRETTIER_DEBUG",
|
|
1248
|
+
"PRETTIER_FALLBACK_RESOLVE",
|
|
1249
|
+
"RAITON_ACCESS_LOG",
|
|
1250
|
+
"RAITON_METRICS_PATH",
|
|
1251
|
+
"RAITON_NATURAL_MODE",
|
|
1252
|
+
"RAITON_OBSERVABILITY",
|
|
1253
|
+
"RAITON_OTEL_ENDPOINT",
|
|
1254
|
+
"RAITON_REQUEST_ID_HEADER",
|
|
1255
|
+
"RAITON_SHUTDOWN_TIMEOUT_MS",
|
|
1256
|
+
"REDIS_URL",
|
|
1257
|
+
"TERM",
|
|
1258
|
+
"TERM_PROGRAM",
|
|
1259
|
+
"TEST_GRACEFUL_FS_GLOBAL_PATCH",
|
|
1260
|
+
"TEST_PSEUDOMAP",
|
|
1261
|
+
"TMPDIR",
|
|
1262
|
+
"USER",
|
|
1263
|
+
"USERNAME",
|
|
1264
|
+
"USERPROFILE",
|
|
1265
|
+
"VALKEY_URL",
|
|
1266
|
+
"VISUAL",
|
|
1267
|
+
"XDG_RUNTIME_DIR"
|
|
1268
|
+
],
|
|
1269
|
+
"mcp": []
|
|
1270
|
+
}
|
|
1271
|
+
```
|