diff --git a/Sources/ManageableUsers/ManageableUsers.swift b/Sources/ManageableUsers/ManageableUsers.swift index 5e7961f..1eca2d8 100644 --- a/Sources/ManageableUsers/ManageableUsers.swift +++ b/Sources/ManageableUsers/ManageableUsers.swift @@ -4,14 +4,22 @@ import FluentPostgresDriver import SwiftSMTPVapor public struct ManageableUsers { - public static func configure (_ app: Application, mainMenu: [MenuItem] = [], homePageName: String = "Home", userAdminPageName: String = "User Administration") async throws { - app.databases.use(DatabaseConfigurationFactory.postgres(configuration: .init( - hostname: Environment.get("DATABASE_HOST") ?? "localhost", - port: Environment.get("DATABASE_PORT").flatMap(Int.init(_:)) ?? SQLPostgresConfiguration.ianaPortNumber, - username: Environment.get("DATABASE_USERNAME") ?? "sampleapp", - password: Environment.get("DATABASE_PASSWORD") ?? "sampleapp_password", - database: Environment.get("DATABASE_NAME") ?? "sampleapp", - tls: .prefer(try .init(configuration: .clientDefault))) + public static func configure (_ app: Application, + mainMenu: [MenuItem] = [], + homePageName: String = "Home", + userAdminPageName: String = "User Administration", + maxConnectionsPerEventLoop: Int = 1, + connectionPoolTimeout: TimeAmount = .seconds(10), + sqlLogLevel: Logger.Level = .debug) async throws { + app.databases.use(DatabaseConfigurationFactory.postgres(configuration: .init (hostname: Environment.get("DATABASE_HOST") ?? "localhost", + port: Environment.get("DATABASE_PORT").flatMap(Int.init(_:)) ?? SQLPostgresConfiguration.ianaPortNumber, + username: Environment.get("DATABASE_USERNAME") ?? "sampleapp", + password: Environment.get("DATABASE_PASSWORD") ?? "sampleapp_password", + database: Environment.get("DATABASE_NAME") ?? "sampleapp", + tls: .prefer(try .init(configuration: .clientDefault))), + maxConnectionsPerEventLoop: maxConnectionsPerEventLoop, + connectionPoolTimeout: connectionPoolTimeout, + sqlLogLevel: sqlLogLevel ), as: .psql) _ = try Environment.baseURL