#Read file at application configuration

1 messages · Page 1 of 1 (latest)

valid heath
#

I'm trying to load my JWT during application configuration

func configure(_ application: Application) async throws {
    // Value of type 'NonBlockingFileIO' has no member 'collectFile'
    var buffer = try await application.fileio.collectFile(at: "")
    let pem = buffer.readString(length: buffer.readableBytes)!
    try application.jwt.signers.use(.es256(key: .private(pem: pem)), kid: "ECDSA")
}

How would one approach this?

noble igloo
#

Easiest way is use NIOFileSystem

valid heath
#

Cool, I'll check that out! As a follow up, what would be the reasoning to make the init of the FileIO internal?

noble igloo
#

Because a lot of the helpers in it are scoped to Request. It's essentially just a wrapper around NIOs old file APIs for constructing responses

#

NIOFileSystem is so much better