Guest User

Untitled

a guest
Oct 22nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import Vapor
  2. import Fluent
  3. import FluentMySQL
  4.  
  5. public func configure(
  6. _ config: inout Config,
  7. _ env: inout Environment,
  8. _ services: inout Services
  9. ) throws {
  10. let router = EngineRouter.default()
  11. try routes(router)
  12. services.register(router, as: Router.self)
  13.  
  14. try services.register(FluentMySQLProvider())
  15.  
  16. let mySQLUser = Environment.get("MYSQL_USER") ?? ""
  17. let mySQLPassword = Environment.get("MYSQL_PASSWORD") ?? ""
  18. let mySQLDatabase = Environment.get("MYSQL_DATABASE") ?? ""
  19. let mySQLIP = Environment.get("MYSQL_IP") ?? ""
  20. let databaseConfig = MySQLDatabaseConfig(hostname: mySQLIP, port: 3306, username: mySQLUser, password: mySQLPassword, database: mySQLDatabase)
  21. services.register(databaseConfig)
  22.  
  23. var migrationConfig = MigrationConfig()
  24. migrationConfig.add(model: Todo.self, database: .mysql)
  25. services.register(migrationConfig)
  26. }
Add Comment
Please, Sign In to add comment