Skip to content

Commit deff640

Browse files
committed
improvement: add rpc routes & basic react setup in installer
1 parent 1653b4e commit deff640

File tree

4 files changed

+574
-46
lines changed

4 files changed

+574
-46
lines changed

README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,27 @@ Generate type-safe TypeScript clients directly from your Elixir Ash resources, e
1818

1919
**Get up and running in under 5 minutes:**
2020

21-
### 1. Installation
21+
### 1. Installation & Setup
22+
23+
**Option A: Automatic Setup with Igniter (Recommended)**
24+
25+
Add AshTypescript to your project and run the automated installer:
26+
27+
```bash
28+
# Add ash_typescript to your mix.exs and install
29+
mix igniter.install ash_typescript
30+
31+
# For a full-stack Phoenix + React setup, use the --react flag:
32+
mix igniter.install ash_typescript --react
33+
```
34+
35+
The installer automatically:
36+
- ✅ Adds AshTypescript to your dependencies
37+
- ✅ Configures AshTypescript settings in `config.exs`
38+
- ✅ Creates RPC controller and routes
39+
- ✅ With `--react`: Sets up React + TypeScript environment, and a getting started guide
40+
41+
**Option B: Manual Installation**
2242

2343
Add to your `mix.exs`:
2444

@@ -32,6 +52,8 @@ end
3252

3353
### 2. Configure your domain
3454

55+
**Note:** If you used the automatic installer (`mix igniter.install ash_typescript`), you can skip to step 5. The following steps are only needed for manual installation.
56+
3557
```elixir
3658
defmodule MyApp.Domain do
3759
use Ash.Domain, extensions: [AshTypescript.Rpc]
@@ -87,6 +109,8 @@ end
87109

88110
### 5. Generate TypeScript types
89111

112+
**After using the installer or completing manual setup:**
113+
90114
**Recommended approach** (runs codegen for all Ash extensions in your project):
91115
```bash
92116
mix ash.codegen --dev"
@@ -116,6 +140,25 @@ const newTodo = await createTodo({
116140
117141
**🎉 That's it!** Your TypeScript frontend now has compile-time type safety for your Elixir backend.
118142
143+
### React Setup (with `--react` flag)
144+
145+
When you use `mix igniter.install ash_typescript --react`, the installer creates a full Phoenix + React + TypeScript setup:
146+
147+
- **📦 Package.json** with React 19 & TypeScript
148+
- **⚛️ React components** with a beautiful welcome page and documentation
149+
- **🎨 Tailwind CSS** integration with modern styling
150+
- **🔧 Build configuration** with esbuild and TypeScript compilation
151+
- **📄 Templates** with proper script loading and syntax highlighting
152+
- **🌐 Getting started guide** accessible at `/ash-typescript` in your Phoenix app
153+
154+
The welcome page includes:
155+
- Step-by-step setup instructions
156+
- Code examples with syntax highlighting
157+
- Links to documentation and demo projects
158+
- Type-safe RPC function examples
159+
160+
Visit `http://localhost:4000/ash-typescript` after running your Phoenix server to see the interactive guide!
161+
119162
## 🚀 Features
120163
121164
- **🔥 Zero-config TypeScript generation** - Automatically generates types from Ash resources
@@ -1128,6 +1171,30 @@ interface TodoFieldsSchema {
11281171
11291172
## 🛠️ Mix Tasks
11301173
1174+
### Installation Commands
1175+
1176+
#### `mix igniter.install ash_typescript` (Recommended)
1177+
1178+
**Automated installer** that sets up everything you need to get started with AshTypescript.
1179+
1180+
```bash
1181+
# Basic installation (RPC setup only)
1182+
mix igniter.install ash_typescript
1183+
1184+
# Full-stack React + TypeScript setup
1185+
mix igniter.install ash_typescript --react
1186+
```
1187+
1188+
**What it does:**
1189+
- Adds AshTypescript to your dependencies and runs `mix deps.get`
1190+
- Configures AshTypescript settings in `config/config.exs`
1191+
- Creates RPC controller (`lib/*_web/controllers/ash_typescript_rpc_controller.ex`)
1192+
- Adds RPC routes to your Phoenix router
1193+
- **With `--react`**: Sets up complete React + TypeScript environment
1194+
- **With `--react`**: Creates welcome page with getting started guide
1195+
1196+
**When to use**: For new projects or when adding AshTypescript to existing projects. This is the recommended approach.
1197+
11311198
### Code Generation Commands
11321199
11331200
#### `mix ash.codegen` (Recommended)

0 commit comments

Comments
 (0)