diff --git a/backend/springboot/PathVariable.md b/backend/springboot/PathVariable.md new file mode 100644 index 0000000..db32a58 --- /dev/null +++ b/backend/springboot/PathVariable.md @@ -0,0 +1,17 @@ +# URL Path Variable Matching + +* [Reference](https://www.baeldung.com/spring-5-mvc-url-matching) + +| Pattern | Pattern String | Example | Matches | Remark | +| --------------- | ----------------------- | ------------------ | -------------------- | --------------------------- | +| {*foo} | /spring/{*id} | /spring/bb/tutor | /bb/tutor | | +| | | /spring/bb | /bb | | +| {*filepaths} | /files/{*filepaths} | /files/hello.txt | content of hello.txt | RouterFunctions.resources() | +| ? | /spring/t?st | /spring/test | | | +| * | /spring/*Id | /spring/TutorId | | | +| ** | /spring/** | /spring/xx/yy/xx | | | +| {params:[a-z]+} | /spring/{parama:[a-z]+} | /spring/parama=abc | abc | | +| {var1}_{var2} | /spring/{var1}_{var2} | /spring/aa_bb | aa,bb | | + + + diff --git a/local/README.md b/local-remote-setup/README.md similarity index 100% rename from local/README.md rename to local-remote-setup/README.md diff --git a/local-remote-setup/analytics-dashboard.md b/local-remote-setup/analytics-dashboard.md new file mode 100644 index 0000000..594b68e --- /dev/null +++ b/local-remote-setup/analytics-dashboard.md @@ -0,0 +1,104 @@ +# Local Debugging Setup (Advance) + +* IntelliJ IDEAS + +* To bypass Spring Security to troubleshoot resource module independently, use this annotation + + * remove `@EnableResourceServer` + * add exclusion `exclude={SecurityAutoConfiguration.class}` + + ```java + @SpringBootApplication(exclude={SecurityAutoConfiguration.class}) + @RestController + //@EnableResourceServer + //@EnableScheduling + public class ResourceApplication { + ... + } + ``` + +* Setup debugger environment + + * for remote db. + * Note : For `authserver`, not able to launch if remote db is Read-Only replica as the code will execute `schema.sql` against `uaa` table, which required write access + + ```text + DATABASE_SERVER_HOST=127.0.0.1;DATABASE=razerpay-malaysia-product;DATABASE_SERVER_USERNAME=tenghieyik;DATABASE_SERVER_PASSWORD=Razer*3ngF0RlIF32 + ``` + + * for local db (according to your local db setup) + + ```text + DATABASE_SERVER_HOST=127.0.0.1;DATABASE=razerpay-malaysia-product;DATABASE_SERVER_USERNAME=razerpay;DATABASE_SERVER_PASSWORD=razerpay-singapore + ``` + +* Happy debugging !!!! + + + +## Remote DB connection via tunnel (Malaysia) + +* SSH tunnel setup at local computer + + * Connect to Malaysia VPN + + * Setup SSH Tunnel to an authorised EC2 for connecting to Malaysia sql sb. + + ```shell + $ ssh -L 3306:rr-zf81fzm6ija52q623.mysql.kualalumpur.rds.aliyuncs.com:3306 tenghieyik@172.22.4.252 + ``` + + * Test tunnel setup connection using `MySQL Workbench` to connect `localhost:3306` + * Setup IntelliJ setting to connect DB via `localhost:3306` + +### For docker container setup + +* Connect remote db from docker container via docker host SSH tunnel + + * SSH tunnel + + ```shell + $ ssh -L host.docker.internal:3306:rr-zf81fzm6ija52q623.mysql.kualalumpur.rds.aliyuncs.com:3306 tenghieyik@172.22.4.252 + + // grab the host.docker.internal IP Address + $ ping host.docker.internal + + Pinging host.docker.internal [192.168.0.132] with 32 bytes of data: + Reply from 192.168.0.132: bytes=32 time<1ms TTL=128 + Reply from 192.168.0.132: bytes=32 time<1ms TTL=128 + ... + ``` + + + + * `docker-compose.yml` + + ```yml + version: '2.1' + services: + + resource: + image: registry-intl.ap-southeast-3.aliyuncs.com/razerpay-report-malaysia/resource:latest + # restart: always + mem_limit: 2048m + mem_reservation: 1024m + ports: + - "9000:9000" + environment: + - JAVA_TOOL_OPTIONS=-Xmx1024M + - DATABASE_SERVER_HOST=192.168.0.132 + - DATABASE_SERVER_USERNAME=tenghieyik + - DATABASE_SERVER_PASSWORD=Razer*3ngF0RlIF32 + - DATABASE=razerpay-malaysia-product + - MAIL_SERVER_USERNAME= + - MAIL_SERVER_PASSWORD= + logging: + options: + max-size: "50m" + ``` + + * + + + + \ No newline at end of file