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

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

        users.get("me") { req -> U in
            return try req.user()
        }

        return .done(on: container)
    }
}

final class UserCache<U>: Service {
    private let loadUser: (String) throws -> U

    init(loadUser: @escaping (String) throws -> U) {
        self.loadUser = loadUser
    }

    var userId: String? = nil

    private var cachedUser: U?
    func user() throws -> U {
        if let loadedUser = cachedUser {
            return loadedUser
        } else if let userId = userId {
            let user = try loadUser(userId)
            cachedUser = user
            return user
        } else {


extension JWTSigner: Service {}

public typealias UserLoader<U> = (Request, String) throws -> Future<U>

public final class JWTKeychainProvider<U: Content>: Provider {
    private let userCacheFactory: () -> UserCache<U>

    public init(loadUser: @escaping UserLoader<U>) {
        userCacheFactory = { UserCache<U>(loadUser: loadUser) }
    }

