vapor
Originally fromar4mirez/samuel
SKILL.md
Vapor Best Practices
1. Concurrency
- ALWAYS use Swift Concurrency (
async/await) overEventLoopFuture. - Use
req.application.asyncControllerpatterns if using custom executors, but standardasyncroute handlers are preferred.
2. Controllers & Routing
- Organize routes into
RouteCollectionconformances. - Do not put logic in
routes.swift; delegate immediately to a Controller. - Group routes by feature (e.g.,
UsersController,AuthController).
3. Fluent (Database)
- Use
@Parentand@Childrenproperty wrappers correctly. - Always use
DTOs(Data Transfer Objects) implementationContentfor API requests/responses. NEVER return a Fluent Model directly to the client. - Run migrations via
app.migrations.add(...).
4. Environment
- Use
Environment.get("KEY")for configuration. - Support
ProductionvsDevelopmentmodes explicitly inconfigure.swift.
Example Route
func boot(routes: RoutesBuilder) throws {
let users = routes.grouped("users")
users.get(use: index)
}
@Sendable
func index(req: Request) async throws -> [UserDTO] {
let users = try await User.query(on: req.db).all()
return users.map { $0.toDTO() }
}
Weekly Installs
6
Repository
tryswift/try-swift-tokyoGitHub Stars
187
First Seen
Feb 28, 2026
Security Audits
Installed on
opencode6
gemini-cli6
codebuddy6
github-copilot6
codex6
kimi-cli6