Skip to content

Commit d4eb779

Browse files
feat(rn-client-demo): add React Native client demo example
Expo/React Native app demonstrating protoc-gen-ts-client with TaskService CRUD, validation errors, headers, abort, and unwrap. Uses expo/AppEntry as the correct Expo entry point. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c595f89 commit d4eb779

14 files changed

Lines changed: 12563 additions & 0 deletions

File tree

examples/rn-client-demo/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Generated files
2+
api/
3+
app/generated/
4+
5+
# Node.js
6+
app/node_modules/
7+
app/.expo/
8+
9+
# Buf lock file (will be created on first buf dep update)
10+
buf.lock
11+
12+
# Go sum file (will be created on first go mod tidy)
13+
go.sum

examples/rn-client-demo/Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.PHONY: demo generate server install-app start-app clean build-plugins
2+
3+
# Full demo: generate code, start server, install app deps
4+
demo: generate install-app
5+
@echo ""
6+
@echo "Starting Go server in background..."
7+
@go run main.go & SERVER_PID=$$!; \
8+
echo "Waiting for server to be ready..."; \
9+
for i in $$(seq 1 30); do \
10+
if curl -s -o /dev/null http://localhost:3000/api/v1/tasks 2>/dev/null; then \
11+
break; \
12+
fi; \
13+
sleep 1; \
14+
done; \
15+
echo ""; \
16+
echo "Server is ready! Start the Expo app with:"; \
17+
echo " cd app && npx expo start"; \
18+
echo ""; \
19+
echo "Press Ctrl+C to stop the server."; \
20+
wait $$SERVER_PID
21+
22+
# Build the protoc plugin binaries
23+
build-plugins:
24+
@echo "Building protoc plugins..."
25+
@cd ../.. && go build -o bin/protoc-gen-go-http ./cmd/protoc-gen-go-http
26+
@cd ../.. && go build -o bin/protoc-gen-ts-client ./cmd/protoc-gen-ts-client
27+
28+
# Generate Go + TypeScript code from proto
29+
generate: build-plugins
30+
@echo "Fetching buf dependencies..."
31+
@buf dep update
32+
@echo "Generating code..."
33+
@buf generate
34+
@echo "Updating Go modules..."
35+
@go mod tidy
36+
@echo "Code generated successfully"
37+
38+
# Run the Go server (blocks)
39+
server: generate
40+
@go run main.go
41+
42+
# Install Expo app dependencies
43+
install-app:
44+
@echo "Installing Expo app dependencies..."
45+
@cd app && npm install --silent
46+
@cd app && npx expo install --fix
47+
48+
# Start Expo dev server (assumes npm install done)
49+
start-app:
50+
@cd app && npx expo start
51+
52+
# Clean generated files
53+
clean:
54+
@rm -rf api/ app/generated/ app/node_modules/ app/.expo/
55+
@echo "Cleaned generated files"

0 commit comments

Comments
 (0)