Skip to content

Commit f05e146

Browse files
Merge pull request #39 from vimal-tech-starter/feature/new-update-phase-11
Phase 11: Security + Debugging fixes
2 parents 4a4a3d3 + dae276c commit f05e146

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

src/main/java/com/vimaltech/contactapi/controller/ContactController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.time.LocalDateTime;
1313

1414
@RestController
15-
@RequestMapping("/api/v1/contact")
15+
@RequestMapping("/api/v1/contacts")
1616
@RequiredArgsConstructor
1717
public class ContactController {
1818

@@ -32,4 +32,9 @@ public ResponseEntity<ApiResponse> submitContact(
3232

3333
return ResponseEntity.status(HttpStatus.CREATED).body(response);
3434
}
35+
36+
@GetMapping
37+
public ResponseEntity<?> getAllContacts() {
38+
return ResponseEntity.ok(contactService.getAllContacts());
39+
}
3540
}

src/main/java/com/vimaltech/contactapi/exception/GlobalExceptionHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ public ResponseEntity<ApiResponse> handleValidationException(
4040
@ExceptionHandler(Exception.class)
4141
public ResponseEntity<ApiResponse> handleGenericException(Exception ex) {
4242

43-
// 🔥 CRITICAL LINE (THIS WAS MISSING)
44-
log.error("Unhandled exception occurred", ex);
43+
log.error("Unhandled exception occurred: {}", ex.getMessage(), ex);
44+
45+
ex.printStackTrace(); // 🔥 TEMPORARY DEBUG (force output)
4546

4647
ApiResponse response = new ApiResponse(
4748
false,

src/main/java/com/vimaltech/contactapi/service/ContactService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.springframework.stereotype.Service;
88

99
import java.time.LocalDateTime;
10+
import java.util.List;
1011

1112
@Service
1213
@RequiredArgsConstructor
@@ -26,4 +27,8 @@ public void processContact(ContactRequest request) {
2627

2728
contactRepository.save(inquiry);
2829
}
30+
31+
public List<ContactInquiry> getAllContacts() {
32+
return contactRepository.findAll();
33+
}
2934
}

src/main/resources/application-prod.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,22 @@ spring:
1919
main:
2020
banner-mode: off
2121

22+
logging:
23+
level:
24+
root: INFO
25+
com.vimaltech.contactapi: DEBUG
26+
2227
server:
2328
error:
24-
include-stacktrace: never
25-
include-message: never
29+
include-stacktrace: always
30+
include-message: always
2631

2732
springdoc:
2833
api-docs:
2934
enabled: false
3035
swagger-ui:
3136
enabled: false
3237

33-
logging:
34-
level:
35-
root: WARN
36-
com.vimaltech.contactapi: INFO
37-
org.springframework: WARN
38-
org.hibernate: WARN
39-
4038
management:
4139
endpoints:
4240
web:

0 commit comments

Comments
 (0)