<!--
This file was generated by Spark. Do not edit it by hand.
-->
# AshTypescript.TypedController

Spark DSL extension for defining typed controller routes.

This extension generates TypeScript path helper functions and a thin Phoenix
controller from routes configured in the DSL. Unlike `AshTypescript.ControllerResource`,
this is a standalone Spark DSL — not attached to `Ash.Resource`.

Routes contain colocated arguments and handler functions (inline closures or
handler modules implementing `AshTypescript.TypedController.Route`).

## Usage

    defmodule MyApp.Session do
      use AshTypescript.TypedController

      typed_controller do
        module_name MyAppWeb.SessionController

        route :login do
          method :post
          run fn conn, params -> Plug.Conn.send_resp(conn, 200, "OK") end
          argument :code, :string, allow_nil?: false
          argument :remember_me, :boolean
        end

        route :auth do
          method :get
          run fn conn, _params -> Plug.Conn.send_resp(conn, 200, "Auth") end
        end
      end
    end


## typed_controller
Define typed controller routes

### Nested DSLs
 * [route](#typed_controller-route)
   * argument





### Options

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`module_name`](#typed_controller-module_name){: #typed_controller-module_name .spark-required} | `atom` |  | The module name for the generated Phoenix controller (e.g. MyAppWeb.SessionController) |



### typed_controller.route
```elixir
route name
```


Define a route that maps a controller action to a handler.

The handler can be an inline function (fn/2) or a module implementing
the `AshTypescript.TypedController.Route` behaviour. Handlers receive
`(conn, params)` and must return a `%Plug.Conn{}`.


### Nested DSLs
 * [argument](#typed_controller-route-argument)




### Arguments

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`name`](#typed_controller-route-name){: #typed_controller-route-name .spark-required} | `atom` |  | The controller action name (e.g. :login, :auth) |
### Options

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`method`](#typed_controller-route-method){: #typed_controller-route-method .spark-required} | `:get \| :post \| :patch \| :put \| :delete` |  | The HTTP method. Required for all routes. |
| [`run`](#typed_controller-route-run){: #typed_controller-route-run .spark-required} | `(any, any -> any) \| atom` |  | The handler — an fn/2 closure or a module implementing AshTypescript.TypedController.Route |
| [`description`](#typed_controller-route-description){: #typed_controller-route-description } | `String.t` |  | JSDoc description for the generated TypeScript path helper |
| [`deprecated`](#typed_controller-route-deprecated){: #typed_controller-route-deprecated } | `boolean \| String.t` |  | Mark this route as deprecated. Set to true for a default message, or provide a custom deprecation notice. |


### typed_controller.route.argument
```elixir
argument name, type
```


Define an argument for this route.





### Arguments

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`name`](#typed_controller-route-argument-name){: #typed_controller-route-argument-name .spark-required} | `atom` |  | The argument name |
| [`type`](#typed_controller-route-argument-type){: #typed_controller-route-argument-type .spark-required} | `atom \| {atom, keyword}` |  | The Ash type (e.g. :string, :boolean, :integer) |
### Options

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`constraints`](#typed_controller-route-argument-constraints){: #typed_controller-route-argument-constraints } | `keyword` | `[]` | Type constraints |
| [`allow_nil?`](#typed_controller-route-argument-allow_nil?){: #typed_controller-route-argument-allow_nil? } | `boolean` | `true` | Whether this argument can be nil. Set to false to make it required. |
| [`default`](#typed_controller-route-argument-default){: #typed_controller-route-argument-default } | `any` |  | Default value for this argument |





### Introspection

Target: `AshTypescript.TypedController.Dsl.RouteArgument`




### Introspection

Target: `AshTypescript.TypedController.Dsl.Route`





<style type="text/css">.spark-required::after { content: "*"; color: red !important; }</style>
