A fully functional Vapor REST API server for syncing chats with your FMChats iOS/macOS app.
✅ Server is currently running on http://localhost:8080
cd /Users/rob/Projects/Swift/FMChatsServer
./start-server.shOr manually:
swift runlsof -ti:8080 | xargs kill -9Health check:
curl http://localhost:8080/healthWelcome page:
curl http://localhost:8080/Get all chats:
curl http://localhost:8080/chats- Make sure the server is running on http://localhost:8080
- Open your FMChats app (iOS or macOS)
- Create some chats in the app
- Tap the Sync button (🔄) in the toolbar
- Select "Upload to Server"
- Select chats to upload and tap "Upload"
- Chats are now stored on the server AND saved as JSON files in
~/Documents/FMChats/
- Tap the Sync button (🔄) in the toolbar
- Select "Download from Server"
- Browse available chats from the server
- Select chats to download and tap "Download"
- Chats are imported into your app
The server currently stores chats in memory. They will be lost when the server restarts.
All uploaded chats are saved to:
~/Documents/FMChats/{uuid}.json
These files persist even if the server restarts or the app is closed.
The server currently has 1 test chat:
- Title: "Test Chat from Server"
- ID: 550E8400-E29B-41D4-A716-446655440000
- Questions: 1 question about Vapor
You can download this in your app to test the download functionality.
-
Test Upload:
- Create a chat in your FMChats app
- Upload it to the server
- Check
~/Documents/FMChats/for the JSON file
-
Test Download:
- Download the test chat from the server
- Verify it appears in your app
-
Test Round-Trip:
- Create a chat on device A
- Upload to server
- Download to device B (or delete and re-download on same device)
To make this production-ready:
-
Add Database Storage (replace in-memory storage)
- PostgreSQL (recommended)
- MongoDB
- SQLite
-
Add Authentication
- JWT tokens
- User accounts
- Secure endpoints
-
Deploy to Cloud
- Vapor Cloud
- Heroku
- AWS
- Digital Ocean
-
Add Features
- Conflict resolution
- Real-time sync with WebSockets
- Multi-user support
- Chat sharing
FMChatsServer/
├── Package.swift # Dependencies
├── README.md # Full documentation
├── QUICKSTART.md # This file
├── start-server.sh # Startup script
└── Sources/
└── FMChatsServer/
├── FMChatsServer.swift # Main entry point
├── configure.swift # Server configuration
├── Models/
│ └── ChatDTO.swift # Data models
└── Controllers/
└── ChatController.swift # API endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| GET | / |
Welcome message |
| GET | /chats |
Get all chats |
| POST | /chats |
Upload a chat |
| GET | /chats/:id |
Get specific chat |
| DELETE | /chats/:id |
Delete a chat |
lsof -ti:8080 | xargs kill -9cd /Users/rob/Projects/Swift/FMChatsServer
swift package clean
swift build
./start-server.sh- Ensure server is running:
curl http://localhost:8080/health - Check firewall settings
- For iOS simulator: use
http://localhost:8080 - For physical device: use your Mac's IP address (e.g.,
http://192.168.1.100:8080)
Check the app's Documents directory:
ls -la ~/Documents/FMChats/For more detailed information, see the full README.md in this directory.