<commit_before>import Kitura
import SwiftProtobuf
import Foundation

private let router = Router()

router.get("/v1/talks") { request, response, next in
    let data = TalkResponse.with { response in
        let user = User.with {
            $0.id = 1
            $0.type = .speaker
            $0.name = "kitasuke"
            $0.introduction = "Yusuke is an iOS developer at Mercari in San Francisco. He has been working on internationalization of Mercari app in iOS team. he is passionate about learning new technology in iOS. When not coding, you can find him cycling."
            $0.photoURL = "https://res.cloudinary.com/skillsmatter/image/upload/c_crop,g_custom/c_scale,w_96,h_96/v1483978529/zebllx0e1udrvjl1twp3.jpg"
        }
        
        let talk = Talk.with {
            $0.id = 1
            $0.title = "Type-safe API call with Protocol Buffers in Swift"
            $0.desc = "Apple recently open sourced swift-protobuf which is a plugin of Protocol Buffers for swift language. Protocol Buffers enables us to have type safety, make API faster and unify schema of structured data. JSON used to be a reasonable way for API call in most cases, but Protocol Buffers could be another option if we consider these benefits. In this talk, you'll discover examples of usage with swift-protobuf in server and client apps. Yusuke will also highlight pros and cons compare to JSON based on his knowledge and experiences."
            $0.speaker = user
            $0.tags = ["swift", "iOS", "protocol-buffers", "ioscon", "type-safe"]
        }
        
        response.talks = [talk]
    }
    
    response.send(data: try data.serializeProtobuf())
    
    next()
}

router.post("/v1/like") { request, response, next in
    var body = Data()
    
    guard let bytes = try? request.read(into: &body),
        let token = try? LikeRequest(protobuf: body) else {
        return
    }
    
    let error = NetworkError.with {
        $0.code = .badRequest
        $0.message = "Not implemented"
    }
    
    response.status(.badRequest).send(data: try error.serializeProtobuf())
    
    next()
}

Kitura.addHTTPServer(onPort: 8090, with: router)

Kitura.run()
<commit_msg>Log data<commit_after>import Kitura
import SwiftProtobuf
import Foundation

private let router = Router()

router.get("/v1/talks") { request, response, next in
    let data = TalkResponse.with { response in
        let user = User.with {
            $0.id = 1
            $0.type = .speaker
            $0.name = "kitasuke"
            $0.introduction = "Yusuke is an iOS developer at Mercari in San Francisco. He has been working on internationalization of Mercari app in iOS team. he is passionate about learning new technology in iOS. When not coding, you can find him cycling."
            $0.photoURL = "https://res.cloudinary.com/skillsmatter/image/upload/c_crop,g_custom/c_scale,w_96,h_96/v1483978529/zebllx0e1udrvjl1twp3.jpg"
        }
        
        let talk = Talk.with {
            $0.id = 1
            $0.title = "Type-safe API call with Protocol Buffers in Swift"
            $0.desc = "Apple recently open sourced swift-protobuf which is a plugin of Protocol Buffers for swift language. Protocol Buffers enables us to have type safety, make API faster and unify schema of structured data. JSON used to be a reasonable way for API call in most cases, but Protocol Buffers could be another option if we consider these benefits. In this talk, you'll discover examples of usage with swift-protobuf in server and client apps. Yusuke will also highlight pros and cons compare to JSON based on his knowledge and experiences."
            $0.speaker = user
            $0.tags = ["swift", "iOS", "protocol-buffers", "ioscon", "type-safe"]
        }
        
        response.talks = [talk]
    }
    
    print(data)
    response.send(data: try data.serializeProtobuf())
    
    next()
}

router.post("/v1/like") { request, response, next in
    var body = Data()
    
    guard let bytes = try? request.read(into: &body),
        let token = try? LikeRequest(protobuf: body) else {
        return
    }
    
    let error = NetworkError.with {
        $0.code = .badRequest
        $0.message = "Not implemented"
    }
    
    print(error)
    response.status(.badRequest).send(data: try error.serializeProtobuf())
    
    next()
}

Kitura.addHTTPServer(onPort: 8090, with: router)

Kitura.run()

{'fraction_non_alphanumeric': 0.09107468123861566, 'fraction_numerical': 0.017304189435336976, 'mean_word_length': 2.5657467532467533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3795527', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1257, 'n_words': 455}