feat: Refactoring routes to use shared / base routes.

This commit is contained in:
2025-01-21 16:00:16 -05:00
parent 20e58114c0
commit 66074d66f4
15 changed files with 445 additions and 227 deletions

View File

@@ -4,20 +4,6 @@ import Vapor
import VaporElementary
extension Request {
func ensureValidContent<T>(_ decoding: T.Type) throws -> T where T: Content, T: Validatable {
try T.validate(content: self)
return try content.decode(T.self)
}
func ensureIDPathComponent<T: LosslessStringConvertible>(
as decoding: T.Type = UUID.self,
key: String = "id"
) throws -> T {
guard let id = parameters.get(key, as: T.self) else {
throw Abort(.badRequest, reason: "Id not supplied.")
}
return id
}
var isHtmxRequest: Bool {
headers.contains(name: "hx-request")