# Docs - [Arcton](/en/docs): A TypeScript backend framework structured for real applications, with priority-based routing, typed context and a runtime-decoupled core. - Introduction - [What is Arcton?](/en/docs/introduction/what-is-arcton): A TypeScript backend framework built around typed context, an explicit middleware pipeline, and a route tree that modules merge into. - [Philosophy](/en/docs/introduction/philosophy): The principles behind Arcton's API — explicit registration order, types derived from what you wrote, and a core that knows nothing about the runtime. - [Architecture Overview](/en/docs/introduction/architecture-overview): How an Arcton request flows from the runtime through the adapter, the router and the pipeline to your handler. - [Runtime Support](/en/docs/introduction/runtime-support): Running the same Arcton application on Bun or Node.js, and the differences between the two adapters. - [When to Use Arcton](/en/docs/introduction/when-to-use): The kinds of projects Arcton fits, and how it compares conceptually to Express, Hono, Elysia and NestJS. - Getting Started - [Installation](/en/docs/getting-started/installation): Scaffold a new Arcton project with the CLI and choose a runtime and package manager. - [Your First Server](/en/docs/getting-started/first-server): Create an Arcton app, register a route, and start listening for requests. - [Project Structure](/en/docs/getting-started/project-structure): What the scaffolder generates for the Bun and Node.js templates. - [Development](/en/docs/getting-started/development): Run the generated project locally with the template's dev script. - [Deployment](/en/docs/getting-started/deployment): Compile a Bun binary or build and run the Node.js template for production. - Fundamentals - [Application](/en/docs/fundamentals/application): Create an Arcton app with `Arcton()` and see the full surface of an app instance. - [Request Lifecycle](/en/docs/fundamentals/request-lifecycle): How a request moves from the router through validation to your handler and back to a response. - [Context](/en/docs/fundamentals/context): The `ctx` object every middleware, provider and handler receives, and how its type grows with what you register. - [Request](/en/docs/fundamentals/request): Reading the incoming request inside a handler or middleware — headers, method, URL, and the raw body. - [Response](/en/docs/fundamentals/response): How a handler's return value becomes an HTTP response, and how to shape status, headers, and cookies. - Routing - [Routing Overview](/en/docs/routing/overview): Registering routes, the three kinds of path segment, and the rules a route path must follow. - [Path Parameters](/en/docs/routing/path-parameters): Capturing dynamic and wildcard segments, the types Arcton infers for them, and how captured values are decoded. - [Query Parameters](/en/docs/routing/query-parameters): Reading the query string from the context, how repeated keys behave, and how to validate query input. - [Route Precedence](/en/docs/routing/precedence): Which route wins when several could match, how backtracking works, and why a method mismatch stops the search. - [HTTP Methods](/en/docs/routing/http-methods): The seven method shorthands, registering several methods on one path, and how Arcton answers a method it has no handler for. - [Modules](/en/docs/routing/modules): Splitting an application into Arcton instances that merge into a single route tree when mounted. - [WebSockets](/en/docs/routing/websockets): Registering WebSocket routes with app.ws(), the handler callbacks, and how sockets combine with modules. - Middleware - [Middleware Overview](/en/docs/middleware/overview): What a middleware is in Arcton, the onion model, and the three ways to attach one. - [Global Middleware](/en/docs/middleware/global): Registering middleware for every route with app.use(), including the responses Arcton generates itself. - [Scoped Middleware](/en/docs/middleware/scoped): Applying middleware to the routes under a path with app.use(scope, middleware). - [Route Middleware](/en/docs/middleware/route-level): Attaching middleware to a single route, either as arguments before the handler or through the middleware option. - [Execution Order](/en/docs/middleware/execution-order): How Arcton decides which middleware a route runs, why registration order matters, and the one case where it does not. - [Modifying Responses](/en/docs/middleware/modifying-responses): Setting headers and status from middleware, replacing the body after next(), and when the response becomes final. - [CORS](/en/docs/middleware/cors): Adding cross-origin headers with @arcton/cors, including preflight handling and credentialed requests. - Validation - [Validation Overview](/en/docs/validation/overview): Validate params, query and body with a Standard Schema, and read the coerced result straight off `ctx`. - [Params and Query](/en/docs/validation/params-and-query): Validate route params and query strings with a schema and read the coerced result from `ctx`. - [Body](/en/docs/validation/body): Validate a request body with a schema and access the parsed, validated result as `ctx.body`. - [Body Parsers](/en/docs/validation/body-parsers): How Arcton parses a request body by Content-Type before validating it, and how to add your own parser. - [Validation Errors](/en/docs/validation/validation-errors): The exact response Arcton sends when params, query or body validation fails. - Providers - [Providers Overview](/en/docs/providers/overview): Compose typed values onto ctx with provide(), available to everything registered after it. - [Typed Context](/en/docs/providers/typed-context): How provide() grows the type of ctx for everything registered after it, without a namespace. - [Providers vs Middleware](/en/docs/providers/providers-vs-middleware): When to add typed values with provide() and when to use use() for control flow around a request. - Integrations - [Better Auth](/en/docs/integrations/better-auth): Register Better Auth's handler in Arcton and access the current session in your routes. - [OpenAPI & Scalar](/en/docs/integrations/openapi): Generate an OpenAPI 3.1 document from your routes' existing schemas, and serve it through Scalar. - [Logging](/en/docs/integrations/logger): Log every request with @arcton/logger — a request-logging middleware with no runtime dependency. - Errors - [Errors](/en/docs/errors/overview): How Arcton turns a mistake, yours or the caller's, into a response - [Responding with Errors](/en/docs/errors/responding-with-errors): Patterns for answering a request with a response that represents a failure - [Uncaught Errors](/en/docs/errors/uncaught-errors): What happens when a handler, provider, or parser throws - [Global Error Handler](/en/docs/errors/global-error-handler): Catch every otherwise-uncaught error in one place with app.onError() - [Registration Errors](/en/docs/errors/registration-errors): The checks Arcton runs on your routes and middleware before any request arrives - Configuration - [App Config](/en/docs/configuration/app-config): Give an Arcton instance a path prefix with ArctonConfig. - [Listen Options](/en/docs/configuration/listen-options): Configure the port, hostname, adapter and environment label passed to app.listen(). - [Environment](/en/docs/configuration/environment): What the env option does and how to read environment variables in each runtime. - Testing - [Testing](/en/docs/testing/overview): How to test Arcton routes and middleware with bun:test. - [Testing Routes](/en/docs/testing/testing-routes): Test routes end to end with app.listen({ port 0 }) and real fetch. - [Testing Middleware](/en/docs/testing/testing-middleware): Unit-test a Middleware in isolation with a hand-built ctx and a fake next. - Architecture - [Architecture Overview](/en/docs/architecture/overview): The layers of Arcton, what each one owns, and the decisions that shape the rest of the framework. - [Router Internals](/en/docs/architecture/router): Why Arcton stores routes in a tree with three slots per node, and how matching and backtracking follow from that shape. - [Pipeline](/en/docs/architecture/pipeline): Why middleware, providers and validation share one ordered sequence, and why each route keeps its own copy of it. - [Adapters](/en/docs/architecture/adapters): Why serving is a separate layer, what the adapter contract covers, and what it deliberately leaves out. - [Runtime Abstraction](/en/docs/architecture/runtime-abstraction): Why the runtime types live in their own package, and what that buys the core, the adapters and your application. - [Module Composition](/en/docs/architecture/module-composition): Why mounting a module merges route trees at registration instead of delegating to a nested router at request time. - [Design Decisions](/en/docs/architecture/design-decisions): An index of the choices that shape Arcton's API, each with the reasoning behind it. - API Reference - [Arcton](/en/docs/api/arcton): The factory function that creates an application instance - [ArctonApp](/en/docs/api/arcton-app): The interface returned by Arcton() — the surface you register routes, middleware, and providers on - [listen()](/en/docs/api/listen): Starts serving requests and returns a handle to the running server - [Context](/en/docs/api/context): The object passed to every handler, provider, and middleware function - [Middleware Types](/en/docs/api/middleware-types): The function types behind global, scoped, and route middleware, plus the router's internal matching types - [Validation Types](/en/docs/api/validation-types): The StandardSchemaV1 and BodyParser type contracts behind route validation and body parsing. - [Runtime Types](/en/docs/api/runtime-types): The RuntimeAdapter contract and the supporting types an adapter implements. - [Adapters](/en/docs/api/adapters): The bunAdapter and nodeAdapter values that connect Arcton to a runtime. - [HTTP Errors](/en/docs/api/http-errors): HttpError and the ready-to-throw Http status factories, from @arcton/core. - [CORS](/en/docs/api/cors): The cors() middleware factory and its options, from @arcton/cors. - [OpenAPI](/en/docs/api/openapi): The openapi() integration factory and its options, from @arcton/openapi. - [Logger](/en/docs/api/logger): The logger() and createLogger() factories, the Logger interface, and their options, from @arcton/logger. - [CLI](/en/docs/api/cli): Scaffold a new Arcton project with arcton create and its two runtime templates. # Docs - [Arcton](/es/docs): Un framework backend para TypeScript estructurado para aplicaciones reales, con enrutamiento basado en prioridad, contexto tipado y un núcleo desacoplado del runtime. - Introducción - [¿Qué es Arcton?](/es/docs/introduction/what-is-arcton): Un framework backend para TypeScript construido alrededor de contexto tipado, un pipeline de middleware explícito, y un árbol de rutas donde se fusionan los módulos. - [Philosophy](/es/docs/introduction/philosophy): Los principios detrás de la API de Arcton — orden de registro explícito, tipos derivados de lo que escribiste, y un núcleo que no sabe nada del runtime. - [Architecture Overview](/es/docs/introduction/architecture-overview): Cómo fluye un request de Arcton desde el runtime, pasando por el adapter, el router y el pipeline, hasta tu handler. - [Runtime Support](/es/docs/introduction/runtime-support): Correr la misma aplicación de Arcton en Bun o en Node.js, y las diferencias entre los dos adapters. - [When to Use Arcton](/es/docs/introduction/when-to-use): Los tipos de proyectos para los que Arcton encaja, y cómo se compara conceptualmente con Express, Hono, Elysia y NestJS. - Primeros pasos - [Instalación](/es/docs/getting-started/installation): Genera un nuevo proyecto de Arcton con el CLI y elige un runtime y un package manager. - [Tu primer servidor](/es/docs/getting-started/first-server): Crea una app de Arcton, registra una ruta y empieza a escuchar requests. - [Estructura del proyecto](/es/docs/getting-started/project-structure): Qué genera el scaffold para los templates de Bun y Node.js. - [Desarrollo](/es/docs/getting-started/development): Ejecuta el proyecto generado localmente con el script de dev del template. - [Despliegue](/es/docs/getting-started/deployment): Compila un binario de Bun, o compila y ejecuta el template de Node.js para producción. - Fundamentos - [Aplicación](/es/docs/fundamentals/application): Crea una app de Arcton con `Arcton()` y descubre toda la superficie de una instancia de app. - [Ciclo de vida de la request](/es/docs/fundamentals/request-lifecycle): Cómo una request viaja desde el router, pasando por la validación, hasta tu handler y de vuelta a una response. - [Context](/es/docs/fundamentals/context): El objeto `ctx` que recibe todo middleware, provider y handler, y cómo crece su tipo según lo que registres. - [Request](/es/docs/fundamentals/request): Leer la request entrante dentro de un handler o middleware — headers, método, URL y el body crudo. - [Response](/es/docs/fundamentals/response): Cómo el valor de retorno de un handler se convierte en una response HTTP, y cómo darle forma al status, los headers y las cookies. - Enrutamiento - [Routing Overview](/es/docs/routing/overview): Registrar rutas, los tres tipos de segmento de path, y las reglas que debe seguir el path de una ruta. - [Path Parameters](/es/docs/routing/path-parameters): Capturar segmentos dinámicos y wildcard, los tipos que Arcton infiere para ellos, y cómo se decodean los valores capturados. - [Query Parameters](/es/docs/routing/query-parameters): Leer el query string desde el context, cómo se comportan las keys repetidas, y cómo validar el input del query. - [Route Precedence](/es/docs/routing/precedence): Qué ruta gana cuando varias podrían matchear, cómo funciona el backtracking, y por qué un método que no coincide corta la búsqueda. - [HTTP Methods](/es/docs/routing/http-methods): Los siete métodos abreviados, registrar varios métodos en un mismo path, y cómo responde Arcton a un método para el que no tiene handler. - [Modules](/es/docs/routing/modules): Dividir una aplicación en instancias de Arcton que se fusionan en un único árbol de rutas al montarlas. - [WebSockets](/es/docs/routing/websockets): Registrar rutas WebSocket con app.ws(), los callbacks del handler, y cómo se combinan los sockets con los módulos. - Middleware - [Middleware Overview](/es/docs/middleware/overview): Qué es un middleware en Arcton, el modelo onion, y las tres formas de agregar uno. - [Global Middleware](/es/docs/middleware/global): Registrar middleware para cada ruta con app.use(), incluyendo las respuestas que Arcton genera por su cuenta. - [Scoped Middleware](/es/docs/middleware/scoped): Aplicar middleware a las rutas bajo un path con app.use(scope, middleware). - [Route Middleware](/es/docs/middleware/route-level): Agregar middleware a una sola ruta, ya sea como argumentos antes del handler o a través de la opción middleware. - [Execution Order](/es/docs/middleware/execution-order): Cómo decide Arcton qué middleware corre una ruta, por qué importa el orden de registro, y el único caso en el que no importa. - [Modifying Responses](/es/docs/middleware/modifying-responses): Asignar headers y status desde el middleware, reemplazar el body después de next(), y cuándo la respuesta se vuelve final. - [CORS](/es/docs/middleware/cors): Agregar headers cross-origin con @arcton/cors, incluyendo el manejo de preflight y requests con credenciales. - Validación - [Descripción general de validación](/es/docs/validation/overview): Valida params, query y body con un Standard Schema, y lee el resultado ya transformado directamente desde `ctx`. - [Params y Query](/es/docs/validation/params-and-query): Valida los params de ruta y los query strings con un esquema y lee el resultado transformado desde `ctx`. - [Body](/es/docs/validation/body): Valida el body de una request con un esquema y accede al resultado parseado y validado como `ctx.body`. - [Parsers de Body](/es/docs/validation/body-parsers): Cómo Arcton parsea el body de una request según el Content-Type antes de validarlo, y cómo agregar tu propio parser. - [Errores de validación](/es/docs/validation/validation-errors): La response exacta que envía Arcton cuando falla la validación de params, query o body. - Providers - [Descripción general de Providers](/es/docs/providers/overview): Compone valores tipados sobre ctx con provide(), disponibles para todo lo que se registre después. - [Context tipado](/es/docs/providers/typed-context): Cómo provide() hace crecer el tipo de ctx para todo lo que se registre después, sin namespace. - [Providers vs Middleware](/es/docs/providers/providers-vs-middleware): Cuándo agregar valores tipados con provide() y cuándo usar use() para controlar el flujo alrededor de una request. - Integraciones - [Better Auth](/es/docs/integrations/better-auth): Registra el handler de Better Auth en Arcton y accede a la sesión actual en tus rutas. - [OpenAPI & Scalar](/es/docs/integrations/openapi): Genera un documento OpenAPI 3.1 a partir de los schemas que ya tienen tus rutas, y sírvelo a través de Scalar. - [Logging](/es/docs/integrations/logger): Loguea cada request con @arcton/logger — un middleware de logging sin ninguna dependencia en runtime. - Errores - [Errores](/es/docs/errors/overview): Cómo Arcton convierte un error, propio o de quien hace la request, en una respuesta - [Respondiendo con Errores](/es/docs/errors/responding-with-errors): Patrones para responder a una request con una respuesta que representa un fallo - [Errores no Capturados](/es/docs/errors/uncaught-errors): Qué pasa cuando un handler, provider o parser lanza una excepción - [Global Error Handler](/es/docs/errors/global-error-handler): Captura cualquier error no manejado en un solo lugar con app.onError() - [Errores de Registro](/es/docs/errors/registration-errors): Las verificaciones que Arcton hace sobre las rutas y el middleware antes de que llegue cualquier request - Configuración - [Configuración de la App](/es/docs/configuration/app-config): Dale a una instancia de Arcton un prefix de ruta con ArctonConfig. - [Opciones de Listen](/es/docs/configuration/listen-options): Configura el puerto, hostname, adapter y la etiqueta de entorno que se pasan a app.listen(). - [Entorno](/es/docs/configuration/environment): Qué hace la opción env y cómo leer variables de entorno en cada runtime. - Testing - [Pruebas](/es/docs/testing/overview): Cómo testear rutas y middleware de Arcton con bun:test. - [Testing de rutas](/es/docs/testing/testing-routes): Testea rutas de punta a punta con app.listen({ port 0 }) y fetch real. - [Testing de middleware](/es/docs/testing/testing-middleware): Testea un Middleware de forma aislada con un ctx armado a mano y un next falso. - Arquitectura - [Architecture Overview](/es/docs/architecture/overview): Las capas de Arcton, qué es dueño de cada una, y las decisiones que le dan forma al resto del framework. - [Router Internals](/es/docs/architecture/router): Por qué Arcton guarda las rutas en un árbol con tres slots por nodo, y cómo el matching y el backtracking se derivan de esa forma. - [Pipeline](/es/docs/architecture/pipeline): Por qué middleware, providers y validation comparten una única secuencia ordenada, y por qué cada ruta guarda su propia copia de ella. - [Adapters](/es/docs/architecture/adapters): Por qué servir es una capa separada, qué cubre el contrato del adapter, y qué deja afuera a propósito. - [Runtime Abstraction](/es/docs/architecture/runtime-abstraction): Por qué los tipos de runtime viven en su propio paquete, y qué le compra eso al core, a los adapters y a tu aplicación. - [Module Composition](/es/docs/architecture/module-composition): Por qué montar un módulo fusiona árboles de rutas al registrarse en vez de delegar a un router anidado en tiempo de request. - [Design Decisions](/es/docs/architecture/design-decisions): Un índice de las decisiones que le dan forma a la API de Arcton, cada una con el razonamiento detrás. - Referencia de la API - [Arcton](/es/docs/api/arcton): La función factory que crea una instancia de aplicación - [ArctonApp](/es/docs/api/arcton-app): La interfaz que devuelve Arcton() — la superficie sobre la que registras rutas, middleware y providers - [listen()](/es/docs/api/listen): Comienza a atender requests y devuelve un handle al servidor en ejecución - [Context](/es/docs/api/context): El objeto que reciben todo handler, provider y función de middleware - [Tipos de middleware](/es/docs/api/middleware-types): Los tipos de función detrás del middleware global, del middleware con scope y del route middleware, más los tipos internos de matching del router - [Tipos de Validación](/es/docs/api/validation-types): Los contratos de tipo StandardSchemaV1 y BodyParser detrás de la validación de rutas y el parsing del body. - [Tipos de Runtime](/es/docs/api/runtime-types): El contrato RuntimeAdapter y los tipos de soporte que implementa un adapter. - [Adapters](/es/docs/api/adapters): Los valores bunAdapter y nodeAdapter que conectan Arcton con un runtime. - [HTTP Errors](/es/docs/api/http-errors): HttpError y las factories de status Http listas para lanzar, de @arcton/core. - [CORS](/es/docs/api/cors): La factory de middleware cors() y sus opciones, de @arcton/cors. - [OpenAPI](/es/docs/api/openapi): La factory openapi() y sus opciones, de @arcton/openapi. - [Logger](/es/docs/api/logger): Las factories logger() y createLogger(), la interfaz Logger, y sus opciones, de @arcton/logger. - [CLI](/es/docs/api/cli): Scaffoldea un nuevo proyecto de Arcton con arcton create y sus dos templates de runtime.