-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Final merge 🎉
- Loading branch information
Showing
386 changed files
with
31,560 additions
and
7,156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
client-secret=<your-client-secret> | ||
client-id=<your-client-id> | ||
tenant-id=<your-tenant-id> | ||
PGU=<your-postgres-user> | ||
PGP=<your-postgres-password> | ||
POSTGRES_USER=${PGU} | ||
URI=<your-uri> | ||
EXPRESS_SESSION_SECRET=<your-express-session-secret> | ||
PORT=<your-port> | ||
ENVIRONMENT=<your-environment> | ||
DB_HOST=<your-db-host> | ||
DB_PORT=<your-db-port> | ||
DB_NAME=<your-db-name> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,57 @@ | ||
# UGent-6 | ||
![badge](https://github.com/SELab-2/UGent-6/actions/workflows/backend_testing.yaml/badge.svg) | ||
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) | ||
|
||
<img src="https://github.com/SELab-2/UGent-6/assets/15960534/bf16e825-2d96-46af-8dc0-12ec03ba545b" width="700"> | ||
|
||
|
||
|
||
| Student | E-mailadres | | ||
----------------------------------------------------|-----------------------------| | ||
| [Matthias Vaneyck](https://github.com/Matthias-VE) | [email protected] | | ||
| [Inti Danschutter](https://github.com/Aqua-sc) | [email protected] | | ||
| [Arthur Werbrouck](https://github.com/AWerbrouck) | [email protected] | | ||
| [Arne Dierick](https://github.com/arnedierick) | [email protected] | | ||
| [Wout Verdyck](https://github.com/usserwoutV2) | [email protected] | | ||
| [Floris Kornelis Van Dijken](https://github.com/badduck32) | [email protected] | | ||
| [Tristan Verbeken](https://github.com/TR1VER) | [email protected]| | ||
|
||
|
||
[wiki documentation](https://github.com/SELab-2/UGent-6/wiki) | ||
|
||
[api documentation](https://apidog.com/apidoc/project-467959) | ||
## Tree view of the project | ||
|
||
- backend | ||
- app | ||
- src | ||
- main/java/com/ugent/pidgeon | ||
- auth (Authentication related logic) | ||
- config (Configuration settings and beans) | ||
- controllers (Web controllers for handling requests) | ||
- model (models for testing submissions) | ||
- json (request/response bodies) | ||
- postgre (Database models and repositories) | ||
- util (Utility classes and helpers) | ||
- resources (Configuration files, property files etc.) | ||
- test/java/com/ugent/pidgeon (Unit and integration tests) | ||
- database (Database schemas and scripts) | ||
- db (Database related scripts) | ||
- web-bff (Express webserver that manages user authentication with cookie sessions) | ||
|
||
- frontend | ||
- public (Static files like images, fonts, and `index.html`) | ||
- src | ||
- @types (TypeScript type definitions) | ||
- assets (Static assets like images and logos used in the app) | ||
- components (Reusable UI components) | ||
- common (Commonly used components across the application) | ||
- forms (Form components, including project form tabs) | ||
- layout (Components related to layout such as navbars and sidebars) | ||
- hooks (Custom React hooks) | ||
- i18n (Internationalization setup, including language files) | ||
- pages (Component structure for each page) | ||
- providers (Context providers for state management) | ||
- router (Routing and path management) | ||
- theme (Styling themes and fonts) | ||
- util (Utility functions and helpers such as our `apiFetch`) | ||
|
||
https://github.com/SELab-2/UGent-6/wiki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
backend/app/src/main/java/com/ugent/pidgeon/ApiErrorReponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.ugent.pidgeon; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
public record ApiErrorReponse(OffsetDateTime timestamp, int status, String error, String message, String path) { | ||
} |
88 changes: 88 additions & 0 deletions
88
backend/app/src/main/java/com/ugent/pidgeon/GlobalErrorHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package com.ugent.pidgeon; | ||
|
||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import java.time.OffsetDateTime; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.http.converter.HttpMessageNotReadableException; | ||
import org.springframework.web.HttpRequestMethodNotSupportedException; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; | ||
import org.springframework.web.servlet.NoHandlerFoundException; | ||
import org.springframework.web.servlet.resource.NoResourceFoundException; | ||
|
||
@ControllerAdvice | ||
public class GlobalErrorHandler { | ||
|
||
|
||
|
||
private void logError(Exception ex) { | ||
Logger logger = Logger.getGlobal(); | ||
// Log the error with the logger | ||
logger.log(Level.SEVERE, ex.getMessage(), ex); | ||
} | ||
|
||
/* Gets thrown when a invalid json is sent */ | ||
@ExceptionHandler(HttpMessageNotReadableException.class) | ||
public ResponseEntity<ApiErrorReponse> handleHttpMessageNotReadableException(HttpServletRequest request, Exception ex) { | ||
logError(ex); | ||
String path = request.getRequestURI(); | ||
HttpStatus status = HttpStatus.BAD_REQUEST; | ||
return ResponseEntity.status(status).body(new ApiErrorReponse(OffsetDateTime.now(), status.value(),status.getReasonPhrase(), | ||
"Unable to process the request due to invalid or missing data. Please ensure the request body is properly formatted and all required fields are provided.", path)); | ||
} | ||
|
||
/* Gets thrown when endpoint doesn't exist */ | ||
@ExceptionHandler(NoHandlerFoundException.class) | ||
public ResponseEntity<ApiErrorReponse> handleNoHandlerFoundException(HttpServletRequest request, Exception ex) { | ||
logError(ex); | ||
String path = request.getRequestURI(); | ||
HttpStatus status = HttpStatus.NOT_FOUND; | ||
return ResponseEntity.status(status).body(new ApiErrorReponse(OffsetDateTime.now(), status.value(), status.getReasonPhrase(), | ||
"Resource/endpoint doesn't exist", path)); | ||
} | ||
|
||
@ExceptionHandler(NoResourceFoundException.class) | ||
public ResponseEntity<ApiErrorReponse> handleNoResourceFoundException(HttpServletRequest request, Exception ex) { | ||
logError(ex); | ||
String path = request.getRequestURI(); | ||
HttpStatus status = HttpStatus.NOT_FOUND; | ||
return ResponseEntity.status(status).body(new ApiErrorReponse(OffsetDateTime.now(), status.value(), status.getReasonPhrase(), | ||
"Resource/endpoint doesn't exist", path)); | ||
} | ||
|
||
/* Gets thrown when the method is not allowed */ | ||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) | ||
public ResponseEntity<ApiErrorReponse> handleMethodNotSupportedException(HttpServletRequest request, Exception ex) { | ||
logError(ex); | ||
String path = request.getRequestURI(); | ||
HttpStatus status = HttpStatus.METHOD_NOT_ALLOWED; | ||
return ResponseEntity.status(status).body(new ApiErrorReponse(OffsetDateTime.now(), status.value(), status.getReasonPhrase(), | ||
"Method not supported", path)); | ||
} | ||
|
||
/* Gets thrown when u path variable is of the wrong type */ | ||
@ExceptionHandler(MethodArgumentTypeMismatchException.class) | ||
public ResponseEntity<ApiErrorReponse> handleMethodArgumentTypeMismatchException(HttpServletRequest request, Exception ex) { | ||
logError(ex); | ||
String path = request.getRequestURI(); | ||
HttpStatus status = HttpStatus.BAD_REQUEST; | ||
return ResponseEntity.status(status).body(new ApiErrorReponse(OffsetDateTime.now(), status.value(), status.getReasonPhrase(), | ||
"Invalid url argument type", path)); | ||
} | ||
|
||
/* Gets thrown when an unexpected error occurs */ | ||
@ExceptionHandler(Exception.class) | ||
public ResponseEntity<ApiErrorReponse> handleException(HttpServletRequest request, Exception ex) { | ||
logError(ex); | ||
String path = request.getRequestURI(); | ||
HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; | ||
return ResponseEntity.status(status).body(new ApiErrorReponse(OffsetDateTime.now(), status.value(), status.getReasonPhrase(), | ||
"An unexpected error occurred", path)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.