vapor / fluent-postgres-driver

🐘 PostgreSQL driver for Fluent.
MIT License
146 stars 53 forks source link

Add optional TLSConfiguration parameter to the postgres initializers #153

Closed seeppp closed 4 years ago

seeppp commented 4 years ago

Some Postgres databases on Heroku need a custom TLS configuration when SSL is required. But the driver does not have a convenient factory to build a PostgresConfiguration with only DATABASE_URL and the TLSConfiguration.

Therefore, I extended the factory functions so be able to perform this:

let url = URL(string: "https://user:password@host:8080/database")!
let tlsConfiguration = TLSConfiguration.forClient(certificateVerification: .none)
try app.databases.use(.postgres(url: url, tlsConfiguration: tlsConfiguration), as: .psql)

relates to https://github.com/vapor/postgres-kit/issues/186