Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from vapor-community/vapor-4-provider
Update for Vapor 4, implementation moved to `sendgrid-kit`.
- Loading branch information
Showing
18 changed files
with
110 additions
and
667 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: test | ||
on: | ||
- pull_request | ||
jobs: | ||
#sendgrid_macos: | ||
# runs-on: macos-latest | ||
# env: | ||
# DEVELOPER_DIR: /Applications/Xcode_11.4_beta.app/Contents/Developer | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# - run: brew install vapor/tap/vapor-beta | ||
# - run: xcrun swift test --enable-test-discovery --sanitize=thread | ||
sendgrid_xenial: | ||
container: | ||
image: vapor/swift:5.2-xenial | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: swift test --enable-test-discovery --sanitize=thread | ||
sendgrid_bionic: | ||
container: | ||
image: vapor/swift:5.2-bionic | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: swift test --enable-test-discovery --sanitize=thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
/*.xcodeproj | ||
Package.pins | ||
Package.resolved | ||
/.swiftpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
// swift-tools-version:4.0 | ||
// swift-tools-version:5.2 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "SendGrid", | ||
platforms: [ | ||
.macOS(.v10_15) | ||
], | ||
products: [ | ||
.library(name: "SendGrid", targets: ["SendGrid"]) | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"), | ||
], | ||
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0-rc"), | ||
.package(url: "https://github.com/vapor-community/sendgrid-kit.git", from: "1.0.0"), | ||
], | ||
targets: [ | ||
.target(name: "SendGrid", dependencies: ["Vapor"]), | ||
.testTarget(name: "SendGridTests", dependencies: ["Vapor", "SendGrid"]) | ||
.target(name: "SendGrid", dependencies: [ | ||
.product(name: "Vapor", package: "vapor"), | ||
.product(name: "SendGridKit", package: "sendgrid-kit"), | ||
]), | ||
.testTarget(name: "SendGridTests", dependencies: ["SendGrid"]) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Vapor | ||
import SendGridKit | ||
|
||
extension Application { | ||
public struct Sendgrid { | ||
private final class Storage { | ||
let apiKey: String | ||
|
||
init(apiKey: String) { | ||
self.apiKey = apiKey | ||
} | ||
} | ||
|
||
private struct Key: StorageKey { | ||
typealias Value = Storage | ||
} | ||
|
||
private var storage: Storage { | ||
if self.application.storage[Key.self] == nil { | ||
self.initialize() | ||
} | ||
return self.application.storage[Key.self]! | ||
} | ||
|
||
public func initialize() { | ||
guard let apiKey = Environment.process.SENDGRID_API_KEY else { | ||
fatalError("No sendgrid API key provided") | ||
} | ||
|
||
self.application.storage[Key.self] = .init(apiKey: apiKey) | ||
} | ||
|
||
fileprivate let application: Application | ||
|
||
public var client: SendGridClient { .init(httpClient: self.application.client.http, apiKey: self.storage.apiKey) } | ||
} | ||
|
||
public var sendgrid: Sendgrid { .init(application: self) } | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@_exported import SendGridKit |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.