-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/issue-145
- Loading branch information
Showing
7 changed files
with
153 additions
and
24 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
> Don't write any database access code, Install DB2Rest instead. | ||
DB2Rest is an [Apache 2.0 Licensed](https://github.com/kdhrubo/db2rest/blob/master/LICENSE) open-source low-code middleware that provides secure and blazing fast data access layer over | ||
your existing or new databases. You can connect to the most widely used databases like PostgreSQL, MySQL, Oracle, SQL Server, MongoDB to build a REST API in minutes without writing any code. | ||
your existing or new databases. You can connect to the most widely used databases like PostgreSQL, MySQL, Oracle, SQL Server, and MongoDB to build a REST API in minutes without writing any code. | ||
You can now focus on building business logic and beautiful user interfaces at speed. | ||
|
||
|
||
|
@@ -25,26 +25,26 @@ You can now focus on building business logic and beautiful user interfaces at sp | |
<[email protected]> | ||
|
||
|
||
# How it works? | ||
# How does it work? | ||
|
||
![DB2Rest- How it works?](assets/db2rest-hiw.png "DB2Rest") | ||
|
||
|
||
The diagram above shows an application architecture with DB2Rest. DB2Rest provides secure access to the database as REST API within seconds of installation/deployment. | ||
The business logic can be written in your favorite technology frameworks for Java, PHP, Node, .NET or using any serverless framework. The business logic layer uses the database access layer (DBAL) provided | ||
by DB2Rest to query and modify data. The user experience layer can be developed using popular front-end frameworks or low code/no-code platforms. This layer can make use of the business logic layer or directly access secure data layer provided by DB2Rest. | ||
The business logic can be written in your favorite technology frameworks for Java, PHP, Node, .NET, or using any serverless framework. The business logic layer uses the database access layer (DBAL) provided | ||
by DB2Rest to query and modify data. The user experience layer can be developed using popular front-end frameworks or low-code/no-code platforms. This layer can make use of the business logic layer or directly access secure data layer provided by DB2Rest. | ||
|
||
## Benefits | ||
|
||
- No code, no SQL knowledge required, instead use simple REST Query Language (RQL) to retrieve data. | ||
- Accelerate application development by 30x. | ||
- Unlock databases - secure REST API access for legacy data. | ||
- Blazing fast - No ORM, Single SQL Statement, 1 Database round-trip, does not use code generation. | ||
- Support for advanced custom queries, bulk data insert, remote stored procedure calls. | ||
- Support for advanced custom queries, bulk data insert, and remote stored procedure calls. | ||
- Best practices for transaction management, connection pooling, encryption, security - RBAC / data entitlement. | ||
- Deploy and run anywhere - on premise, VM, Kubernetes, any cloud. | ||
- Deploy and run anywhere - on-premise, VM, Kubernetes, or any cloud. | ||
- Zero downtime - adjusts to your evolving database schema. | ||
- Compatible with Devops processes. | ||
- Compatible with DevOps processes. | ||
|
||
|
||
# Installation | ||
|
@@ -66,7 +66,7 @@ Open JDK can be downloaded from [here](https://jdk.java.net/21/). This article f | |
Now that you have successfully downloaded, installed, and verified Java 21, the next step is to get DB2Rest. DB2Rest is shipped | ||
as a single executable Java Archive or jar file So it's super easy to get up and running under a minute. | ||
|
||
To download the latest edition(v-0.0.8) of DB2Rest click [here](https://www.docker.com/get-started/). | ||
To download the latest edition(v-0.0.8) of DB2Rest click [here](https://download.db2rest.com/db2rest-0.0.8.jar). | ||
|
||
### 3. Run DB2Rest. | ||
|
||
|
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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/homihq/db2rest/exception/GlobalExceptionHandler.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 |
---|---|---|
@@ -1,9 +1,40 @@ | ||
package com.homihq.db2rest.exception; | ||
|
||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatusCode; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.MethodArgumentNotValidException; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
import org.springframework.web.context.request.ServletWebRequest; | ||
import org.springframework.web.context.request.WebRequest; | ||
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; | ||
|
||
import java.time.Instant; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
@RestControllerAdvice | ||
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { | ||
|
||
@Override | ||
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, | ||
HttpHeaders headers, | ||
HttpStatusCode status, WebRequest request) { | ||
var body = new LinkedHashMap<>(); | ||
body.put("type", "https://github.com/kdhrubo/db2rest/invalid-arguments"); | ||
body.put("title", "Invalid arguments in the request"); | ||
body.put("status", status.value()); | ||
var errors = ex.getBindingResult() | ||
.getFieldErrors() | ||
.stream() | ||
.map(error -> Map.of(error.getField(), Objects.requireNonNull(error.getDefaultMessage()))) | ||
.toList(); | ||
body.put("detail", errors); | ||
body.put("instance", ((ServletWebRequest) request).getRequest().getRequestURI()); | ||
body.put("errorCategory", "Invalid-Arguments"); | ||
body.put("timestamp", Instant.now()); | ||
return new ResponseEntity<>(body, headers, status); | ||
} | ||
|
||
} |
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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/homihq/db2rest/rest/read/model/QueryRequest.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,19 @@ | ||
package com.homihq.db2rest.rest.read.model; | ||
|
||
import jakarta.validation.constraints.NotEmpty; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.util.Map; | ||
|
||
@Data | ||
@Builder | ||
public class QueryRequest { | ||
|
||
@NotEmpty(message = "Sql statement cannot be empty") | ||
private String sql; | ||
|
||
private Map<String, Object> params; | ||
|
||
private boolean isSingle; | ||
} |
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