DatabaseConfig

For our database to know where to connect to, we need to configure the credentials:

    guard let mysqlUrl = Environment.process.MYSQL_CRED else {        fatalError("No value was found at the given public key environment         'MYSQL_CRED'")    }    guard let url = URL(string: mysqlUrl) else {        fatalError("Cannot parse: \(mysqlUrlString) correctly.")    }    app.databases.use(try DatabaseDriverFactory.mysql(url: url),     as: DatabaseID.mysql)

You can see that, first, we check whether we have the minimum credential variable available. We need this to connect to the database; so, if we don't have it, we will get an error (which will prevent the application from starting). After we have verified it, then we have all we need to register the MySQLDatabase (that ...

Get Hands-On Swift 5 Microservices Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.