Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vapor-community/vapor-aws-lambda-runtime
Run your Vapor api server on AWS Lambda using the official Swift Server runtime.
https://github.com/vapor-community/vapor-aws-lambda-runtime
aws aws-lambda aws-lambda-swift lambda swift swift-server vapor
Last synced: about 4 hours ago
JSON representation
Run your Vapor api server on AWS Lambda using the official Swift Server runtime.
- Host: GitHub
- URL: https://github.com/vapor-community/vapor-aws-lambda-runtime
- Owner: vapor-community
- License: apache-2.0
- Created: 2019-12-30T16:49:45.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-10-23T19:32:37.000Z (about 3 years ago)
- Last Synced: 2024-10-30T17:18:44.630Z (18 days ago)
- Topics: aws, aws-lambda, aws-lambda-swift, lambda, swift, swift-server, vapor
- Language: Swift
- Homepage:
- Size: 48.8 KB
- Stars: 105
- Watchers: 5
- Forks: 10
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# vapor-aws-lambda-runtime
[![Swift 5.2](https://img.shields.io/badge/Swift-5.2-blue.svg)](https://swift.org/download/)
[![Vapor 4](https://img.shields.io/badge/Vapor-4-5AA9E7.svg)](/vapor/vapor)
[![github-actions](https://github.com/fabianfett/vapor-lambda-runtime/workflows/CI/badge.svg)](https://github.com/fabianfett/vapor-lambda-runtime/actions)
[![codecov](https://codecov.io/gh/fabianfett/vapor-lambda-runtime/branch/main/graph/badge.svg)](https://codecov.io/gh/fabianfett/vapor-lambda-runtime)Run your Vapor app on AWS Lambda. This package bridges the communication between [`swift-aws-lambda-runtime`](https://github.com/swift-server/swift-aws-lambda-runtime)
and the [Vapor](https://github.com/vapor/vapor) framework. APIGateway requests are transformed into `Vapor.Request`s and `Vapor.Response`s are written back to the APIGateway. It intents to bring the funcionality of [`aws-lambda-go-api-proxy`](/awslabs/aws-lambda-go-api-proxy) to Vapor.## Status
**Note: Currently this is nothing more than a proof of concept. Use at your own risk. I would like to hear feedback, if you played with this. Please open a GitHub issues for all open ends, you experience.**
What I have tested:
- [x] Routing
- [x] JSON Coding
- [ ] Cors Middleware
- [ ] FluentThere are probably tons of other things that we should test. I haven't done much with Vapor so far. Therefore you will need to help me list the things to test.
Examples:
- [HelloWorld](examples/Hello/Sources/Hello/main.swift)
If you test anything, please open a PR so that we can document the state of affairs better. A super small example would be even better. I plan to create some integration tests with the examples.
## Usage
Add `vapor-aws-lambda-runtime` and `vapor` as dependencies to your project. For this open your `Package.swift`:
```swift
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.0.0")),
.package(url: "https://github.com/fabianfett/vapor-aws-lambda-runtime", .upToNextMajor(from: "0.4.0")),
]
```Add VaporLambdaRuntime as depency to your target:
```swift
targets: [
.target(name: "Hello", dependencies: [
.product(name: "Vapor", package: "vapor"),
.product(name: "VaporAWSLambdaRuntime", package: "vapor-aws-lambda-runtime")
]),
]
```Create a simple Vapor app.
```swift
import Vapor
import VaporAWSLambdaRuntimelet app = Application()
struct Name: Codable {
let name: String
}struct Hello: Content {
let hello: String
}app.get("hello") { (_) -> Hello in
Hello(hello: "world")
}app.post("hello") { req -> Hello in
let name = try req.content.decode(Name.self)
return Hello(hello: name.name)
}
```Next we just need to run the vapor app. To enable running in Lambda, we need to change the "serve" command. Then we can start the app by calling `app.run()`
```swift
app.servers.use(.lambda)try app.run()
```## Contributing
Please feel welcome and encouraged to contribute to vapor-aws-lambda-runtime. The current version has a long way to go before being ready for production use and help is always welcome.
If you've found a bug, have a suggestion or need help getting started, please open an Issue or a PR. If you use this package, I'd be grateful for sharing your experience.
If you like this project, I'm excited about GitHub stars. 🤓