diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8c8d47..e6fb92f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,12 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: | ${{ runner.os }}-gradle- + - name: Replace placeholders in application.properties + run: | + sed -i "s|JDBC_DATABASE_URL=.*|JDBC_DATABASE_URL=${{ secrets.JDBC_DATABASE_URL }}|g" src/main/resources/application.properties + sed -i "s|JDBC_DATABASE_USERNAME=.*|JDBC_DATABASE_USERNAME=${{ secrets.JDBC_DATABASE_USERNAME }}|g" src/main/resources/application.properties + sed -i "s|JDBC_DATABASE_PASSWORD=.*|JDBC_DATABASE_PASSWORD=${{ secrets.JDBC_DATABASE_PASSWORD }}|g" src/main/resources/application.properties + sed -i "s|PRODUCTION=.*|PRODUCTION=${{ secrets.PRODUCTION }}|g" src/main/resources/application.properties - name: Make gradlew executable run: chmod +x ./gradlew - name: Build with Gradle @@ -75,6 +81,7 @@ jobs: - name: Test with Gradle run: | + sed -i "s|\${JDBC_DATABASE_URL}|${{ secrets.JDBC_DATABASE_URL }}|g" src/main/resources/application-prod.properties ./gradlew check --info --stacktrace ./gradlew test ./gradlew jacocoTestReport diff --git a/src/main/java/snackscription/subscriptionadmin/config/AsyncConfiguration.java b/src/main/java/snackscription/subscriptionadmin/config/AsyncConfiguration.java new file mode 100644 index 0000000..7237d9a --- /dev/null +++ b/src/main/java/snackscription/subscriptionadmin/config/AsyncConfiguration.java @@ -0,0 +1,22 @@ +package snackscription.subscriptionadmin.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.concurrent.Executor; + +@Configuration +@EnableAsync +public class AsyncConfiguration { + @Bean("asyncTaskExecutor") + public Executor asyncTaskExecutor(){ + ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); + taskExecutor.setCorePoolSize(4); + taskExecutor.setQueueCapacity(150); + taskExecutor.setThreadNamePrefix("AsyncTaskThread-"); + taskExecutor.initialize(); + return taskExecutor; + } +} diff --git a/src/main/java/snackscription/subscriptionadmin/controller/AdminController.java b/src/main/java/snackscription/subscriptionadmin/controller/AdminController.java index 8e6818d..db17e53 100644 --- a/src/main/java/snackscription/subscriptionadmin/controller/AdminController.java +++ b/src/main/java/snackscription/subscriptionadmin/controller/AdminController.java @@ -11,6 +11,7 @@ @RestController @RequestMapping("/admin") +@CrossOrigin(origins = "*") public class AdminController { private final AdminService adminService; diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 46b6391..3a64411 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -1,6 +1,6 @@ -spring.datasource.url=${JDBC_DATABASE_URL} -spring.datasource.username=${JDBC_DATABASE_USERNAME} -spring.datasource.password=${JDBC_DATABASE_PASSWORD} +spring.datasource.url=jdbc:postgresql://aws-0-ap-southeast-1.pooler.supabase.com:543user=postgres.thnfvhxtvcbfxndlxdze&password=YouMakeStrayKidsStay +spring.datasource.username=postgres.thnfvhxtvcbfxndlxdze +spring.datasource.password=YouMakeStrayKidsStay spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.properties.hibernate.format_sql=true diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 576dd7d..cac1712 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,2 @@ spring.application.name=subscription-admin -spring.profiles.active=${PRODUCTION:dev} \ No newline at end of file +spring.profiles.active=${PRODUCTION:prod} \ No newline at end of file