Skip to content

Commit de18ccc

Browse files
authored
Merge pull request #89 from BusConnectTeam/feature/user-service-9-auth-config
Feature/user service 9 auth config
2 parents 0d4d592 + 01ced7b commit de18ccc

54 files changed

Lines changed: 9319 additions & 368 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212
# ============================================
1313

1414
# PostgreSQL Database
15-
POSTGRES_USER=your_db_user
16-
POSTGRES_PASSWORD=your_secure_password_here
17-
POSTGRES_DB=your_database_name
15+
POSTGRES_DB=busconnectdb
16+
POSTGRES_USER=busconnect_user
17+
POSTGRES_PASSWORD=your_secure_password_here # Cambia por tu contraseña real
1818

19-
# Database Connection (for microservices)
20-
DB_USERNAME=your_db_user
21-
DB_PASSWORD=your_secure_password_here
22-
DB_HOST=postgres
23-
DB_PORT=5432

.github/issue_84_content.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
## 📋 Summary
2+
3+
Added optional `userId` query parameter to POST `/api/routes/calculate` endpoint for user activity tracking in logs.
4+
5+
## 🎯 Motivation
6+
7+
Enable tracking of which users are searching for routes without adding database complexity. This provides valuable insights through logs for analytics and debugging purposes.
8+
9+
## 🔧 Changes Implemented
10+
11+
### Modified Files
12+
- `catalog-service/src/main/java/com/busconnect/catalogservice/controller/RouteController.java`
13+
14+
### Technical Details
15+
16+
**Endpoint signature:**
17+
```java
18+
@PostMapping("/calculate")
19+
public Mono<ResponseEntity<RouteResultResponse>> calculateRoute(
20+
@Valid @RequestBody CalculateRouteRequest request,
21+
@RequestParam(required = false) Long userId
22+
)
23+
```
24+
25+
**Logging behavior:**
26+
- If `userId` is provided: `User {id} requested route: {origin} -> {destination}`
27+
- If `userId` is null: `Route calculation requested: {origin} -> {destination}`
28+
29+
## 📝 Usage Examples
30+
31+
**With userId:**
32+
```bash
33+
curl -X POST "http://localhost:8083/api/routes/calculate?userId=2" \
34+
-H "Content-Type: application/json" \
35+
-d '{"originMunicipality":"Barcelona","destinationMunicipality":"Girona"}'
36+
```
37+
38+
**Without userId (backwards compatible):**
39+
```bash
40+
curl -X POST "http://localhost:8083/api/routes/calculate" \
41+
-H "Content-Type: application/json" \
42+
-d '{"originMunicipality":"Barcelona","destinationMunicipality":"Girona"}'
43+
```
44+
45+
## 🔍 Log Output Example
46+
47+
```
48+
2026-01-18 13:28:18 - c.b.c.controller.RouteController - User 2 requested route: Barcelona -> Tarragona
49+
```
50+
51+
## ✅ Benefits
52+
53+
-**No database changes required** - Pure logging solution
54+
-**Backwards compatible** - Parameter is optional
55+
-**Easy to implement** - Minimal code changes
56+
-**Immediate insights** - Track user behavior in real-time
57+
-**Frontend ready** - Can be integrated with user session context
58+
59+
## 🚀 Next Steps (Frontend)
60+
61+
This backend change enables the following frontend features:
62+
1. User session context with localStorage
63+
2. Search history tracking per user
64+
3. Personalized dashboard with recent searches
65+
4. User-specific analytics
66+
67+
## 🧪 Testing
68+
69+
Tested with:
70+
- User ID 2 (Joan García): ✅ Logged correctly
71+
- No user ID: ✅ Falls back to generic log
72+
- API response: ✅ Unchanged, fully backwards compatible
73+
74+
## 📦 Deployment Status
75+
76+
- [x] Code changes implemented
77+
- [x] Service rebuilt and redeployed
78+
- [x] Manual testing completed
79+
- [x] Logs verified
80+
81+
---
82+
83+
**Implementado por:** @Irina-Ichim
84+
**Fecha:** 2026-01-18
85+
**Servicio afectado:** catalog-service
86+
**Puerto:** 8083
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build & Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
branches:
10+
- main
11+
- develop
12+
workflow_dispatch:
13+
14+
jobs:
15+
build:
16+
name: Build & Test
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up JDK 21
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: '21'
27+
distribution: 'temurin'
28+
cache: maven
29+
30+
- name: Build and test with Maven
31+
run: mvn clean verify
32+
33+
- name: Build successful
34+
if: success()
35+
run: echo "Build and tests passed! Render will deploy automatically."

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,20 @@ target/
4040

4141
# Maven target directory
4242
**/target/
43+
44+
# IDE and Editor files
45+
.claude/
46+
.vscode/
47+
.DS_Store
48+
49+
# Maven
50+
.mvn/
51+
mvnw
52+
mvnw.cmd
53+
54+
# Logs
55+
logs/
56+
*.log.*
57+
58+
# OS
59+
Thumbs.db

0 commit comments

Comments
 (0)