Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples with HB2-beta.5 #80

Merged
merged 9 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
--exclude .build

# rules
--disable redundantReturn, extensionAccessControl, unusedArguments
--disable redundantReturn, extensionAccessControl, unusedArguments, yodaconditions
adam-fowler marked this conversation as resolved.
Show resolved Hide resolved

# format options
--ifdef no-indent
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SHELL=/bin/bash

check:
./scripts/run-checks.sh

format:
swiftformat .

all:
./scripts/build-all.sh
tib marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 7 additions & 13 deletions auth-cognito/Package.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "auth-cognito",
platforms: [.macOS(.v14)],
platforms: [
.macOS(.v14),
],
dependencies: [
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0-beta.1"),
.package(url: "https://github.com/hummingbird-project/hummingbird-auth.git", from: "2.0.0-beta.1"),
.package(url: "https://github.com/adam-fowler/soto-cognito-authentication-kit.git", from: "5.0.0-alpha.1"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.0.0"),
.package(url: "https://github.com/hummingbird-project/hummingbird", from: "2.0.0-beta.5"),
.package(url: "https://github.com/hummingbird-project/hummingbird-auth", from: "2.0.0-beta.2"),
.package(url: "https://github.com/adam-fowler/soto-cognito-authentication-kit", from: "5.0.0-alpha.1"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.4.0"),
],
targets: [
.executableTarget(
Expand All @@ -22,12 +22,6 @@ let package = Package(
.product(name: "SotoCognitoAuthenticationKit", package: "soto-cognito-authentication-kit"),
.product(name: "SotoCognitoAuthenticationSRP", package: "soto-cognito-authentication-kit"),
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
swiftSettings: [
// Enable better optimizations when building in Release configuration. Despite the use of
// the `.unsafeFlags` construct required by SwiftPM, this flag is recommended for Release
// builds. See <https://github.com/swift-server/guides#building-for-production> for details.
.unsafeFlags(["-cross-module-optimization"], .when(configuration: .release)),
]
),
.testTarget(
Expand Down
12 changes: 9 additions & 3 deletions auth-cognito/Sources/App/Application+build.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AsyncHTTPClient
import Hummingbird
import HummingbirdAuth
import HummingbirdRouter
Expand All @@ -14,9 +15,11 @@ struct AWSClientService: Service {
}
}

func buildApplication(configuration: ApplicationConfiguration) async throws -> some ApplicationProtocol {
func buildApplication(
configuration: ApplicationConfiguration
) async throws -> some ApplicationProtocol {
// setup Soto
let awsClient = AWSClient(httpClientProvider: .createNew)
let awsClient = AWSClient(httpClient: HTTPClient.shared)
let cognitoIdentityProvider = CognitoIdentityProvider(client: awsClient, region: .euwest1)
// setup SotoCognitoAuthentication
let env = try await Environment().merging(with: .dotEnv())
Expand All @@ -36,7 +39,10 @@ func buildApplication(configuration: ApplicationConfiguration) async throws -> s

let router = RouterBuilder(context: AuthCognitoRequestContext.self) {
AWSErrorMiddleware()
UserController(cognitoAuthenticatable: authenticatable, cognitoIdentityProvider: cognitoIdentityProvider).endpoints
UserController(
cognitoAuthenticatable: authenticatable,
cognitoIdentityProvider: cognitoIdentityProvider
).endpoints
}

var app = Application(router: router)
Expand Down
Loading
Loading