AkrosAG / Akros-Marketplace

Apache License 2.0
3 stars 5 forks source link

Clean up database connection in backend #110

Open stefanleminh opened 2 years ago

stefanleminh commented 2 years ago

The database connection in the backend is all over the place and needs to be cleaned up. It gets initialized in three different ways depending on the environment - Optimally it should be one and the same.

@Bean
  public DataSource getPostgresDataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("org.postgresql.Driver");

    if (System.getenv(POSTGRES_DB_URL_ENV) != null && System.getenv(POSTGRES_DB_URL_ENV).length() > 0) {
      // using container orchestration
      dataSource.setUrl(System.getenv(POSTGRES_DB_URL_ENV));
      dataSource.setUsername("am");
      dataSource.setPassword("am");
    }
    else if(!connectionStringRemote.isEmpty()){
      dataSource.setUrl(connectionStringRemote);
    } else {
      dataSource.setUrl(connectionStringLocale);
      dataSource.setUsername("am");
      dataSource.setPassword("am");
    }

    return dataSource;
  }
ghost commented 2 years ago

Task on hold, because don't have permissions to Azure - Stefan has notified Andre for that and we are waiting for his response. Changes for local development are committed to a branch.