Swiftpack.co -  hummingbird-project/hummingbird-lambda as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
hummingbird-project/hummingbird-lambda
Hummingbird running inside an AWS Lambda
.package(url: "https://github.com/hummingbird-project/hummingbird-lambda.git", from: "0.3.1")

Hummingbird Lambda

Run Hummingbird inside an AWS Lambda

Usage

Create struct conforming to HBLambda. Setup your application in the init function: add your middleware, add route handlers etc

struct MyHandler: HBLambda {
    // define input and output
    typealias In = APIGateway.Request
    typealias Out = APIGateway.Response
    
    init(_ app: HBApplication) {
        app.middleware.add(HBLogRequestsMiddleware(.debug))
        app.router.get("hello") { _ in
            return "Hello"
        }
    }
}

Lambda.run { context in
    return HBLambdaHandler<MyHandler>(context: context)
}

The In and Out types define your input and output objects. If you are using an APIGateway REST interface to invoke your Lambda then set these to APIGateway.Request and APIGateway.Response respectively. If you are using an APIGateway HTML interface then set these to APIGateway.V2.Request and APIGateway.V2.Response. If you are using any other In/Out types you will need to implement the request(context:application:from:) and output(from:) methods yourself.

GitHub

link
Stars: 3
Last commit: 5 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

v0.3.1
12 weeks ago
  • Allow HBLambda.init to throw errors
  • CI now uses swift 5.4

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API