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 s3-upload example for HB 2.0 #75

Merged
merged 4 commits into from
May 6, 2024
Merged

Update s3-upload example for HB 2.0 #75

merged 4 commits into from
May 6, 2024

Conversation

adam-fowler
Copy link
Member

No description provided.

@adam-fowler adam-fowler requested a review from Joannis May 1, 2024 13:38
upload-s3/Package.swift Outdated Show resolved Hide resolved
Comment on lines 64 to 92
/*
extension HBApplication {
/// configure your application
/// add middleware
/// setup the encoder/decoder
/// add your routes
func configure(_: AppArguments) throws {
let env = HBEnvironment()
guard let bucket = env.get("s3_upload_bucket") else {
preconditionFailure("Requires \"s3_upload_bucket\" environment variable")
}

self.encoder = JSONEncoder()
self.middleware.add(HBLogRequestsMiddleware(.info))
self.aws.client = AWSClient(httpClientProvider: .createNewWithEventLoopGroup(self.eventLoopGroup))
let s3 = S3(client: self.aws.client, region: .euwest1)

let fileController = S3FileController(
s3: s3,
bucket: bucket,
folder: env.get("s3_upload_folder") ?? "hb-upload-s3"
)
fileController.addRoutes(to: self.router.group("files"))

self.router.get("/health") { _ -> HTTPResponseStatus in
return .ok
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code

}
}

func buildApplication(_ args: AppArguments) -> some ApplicationProtocol {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func buildApplication(_ args: AppArguments) -> some ApplicationProtocol {
func buildApplication(_ args: some AppArguments) -> some ApplicationProtocol {

@adam-fowler adam-fowler merged commit 8689ee8 into main May 6, 2024
1 check passed
@adam-fowler adam-fowler deleted the s3-upload-2.0 branch May 6, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants