 
 enum JWTKeychainError: Error {
     case unauthorized
+    case userNotFound
 }
 
 extension JWTKeychainError: AbortError {

        return payload.sub.value
    }

    public func user<U>(userType: U.Type = U.self) throws -> U {
        let userService = try make(UserCache<U>.self)
        return try userService.user()
    }
}


            .grouped(middleware)
            .grouped("users")

        users.get("me") { (request: Request) -> Future<U> in

            try request.user().flatMap(to: U.self) { (u: U) in
                print(u)
                return try request.user()
            }
        }

        return .done(on: container)
    }
}

import Fluent
import Vapor

extension JWTKeychainProvider where U: Model, U.ID == Int, U.Database: QuerySupporting {
    public convenience init() {
        self.init { (request, id) -> Future<U> in
            U.query(on: request).first().map(to: U.self) {
                guard let user = $0 else {
                    throw JWTKeychainError.userNotFound
                }
                return user
            }
        }
    }
}

final class UserCache<U>: Service {
    private let loadUser: UserLoader<U>

    init(loadUser: @escaping UserLoader<U>) {
        self.loadUser = loadUser
    }

    var userId: String? = nil

    private var cachedUser: Future<U>?
    func user(on request: Request) throws -> Future<U> {
        if let cachedUser = cachedUser {
            return cachedUser
        } else if let userId = userId {
            let user = try loadUser(request, userId)
            cachedUser = user
            return user
        } else {
