-
Notifications
You must be signed in to change notification settings - Fork 222
Expand file tree
/
Copy pathRdsWebConfig.java
More file actions
50 lines (43 loc) · 1.55 KB
/
RdsWebConfig.java
File metadata and controls
50 lines (43 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package scorekeep;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import javax.servlet.Filter;
import javax.sql.DataSource;
@Configuration
@EnableAutoConfiguration
@EnableJpaRepositories("scorekeep")
@Profile("pgsql")
public class RdsWebConfig {
private static final Log logger = LogFactory.getLog(WebConfig.class);
@Bean
public Filter SimpleCORSFilter() {
return new SimpleCORSFilter();
}
@Bean
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource() {
logger.info("Initializing PostgreSQL datasource");
return DataSourceBuilder.create()
.driverClassName("org.postgresql.Driver")
.url("jdbc:postgresql://" + System.getenv("RDS_HOSTNAME") + ":" + System.getenv("RDS_PORT") + "/ebdb")
.username(System.getenv("RDS_USERNAME"))
.password(System.getenv("RDS_PASSWORD"))
.build();
}
@Bean
public GameHistoryModel gameHistoryModel() {
return new GameHistoryModel();
}
static {
if ( System.getenv("NOTIFICATION_EMAIL") != null ){
Sns.createSubscription();
}
}
}