feat: Starting users view controller.

This commit is contained in:
2025-01-08 08:02:29 -05:00
parent e86e5facc6
commit 3557227430
5 changed files with 83 additions and 30 deletions

View File

@@ -0,0 +1,36 @@
import Fluent
import Vapor
struct UserViewController: RouteCollection {
private let api = ApiController()
func boot(routes: any RoutesBuilder) throws {
let users = routes.protected.grouped("users")
users.get(use: index(req:))
}
@Sendable
func index(req: Request) async throws -> View {
let users = try await api.usersIndex(req: req)
return try await req.view.render("users", ["users": users])
}
}
struct UserFormCTX: Content {
let htmxTargetUrl: String
let htmxTarget: String
let htmxPushUrl: String
let showConfirmPassword: Bool
let buttonLabel: String
static func signIn(route: String) -> Self {
.init(
htmxTargetUrl: route,
htmxTarget: "body",
htmxPushUrl: "true",
showConfirmPassword: false,
buttonLabel: "Sign In"
)
}
}