This project is meant to provide a simple restful interface to interact with databases. It features the ability to act as a proxy between any servers over a TCP connection. Also, it has the ability to read selected tables and generate an OpenApi spec.
Currently, it supports the following databases:
- PostgresDB
- CockroachDB
mvn clean package
cd universal-database-proxy-rest
java -jar -Dproject.config=cfg/config.json target/universal-database-proxy-rest-1.0.2-fat.jar
- Create a config.json file. You can use the file in
docker/config.json
as a base. - Update the
postgresApi
object.- Set the
enabled
property totrue
- Set the
host
to the address the HTTP Server should attach to. This can belocalhost
or0.0.0.0
orsome.address.com
. - Set the
port
to the port number the HTTP Server should listen for connection on. This can be any valid port number. - Set the
openApiFilePath
to where you want the OpenApi file generated to be stored. For example:./pgOpenApi.yaml
- Now the
database
object holds configuration regarding the database we are trying base of our API from. - Set the
host
to the address of the database. For example:localhost
or0.0.0.0
orsome.address.com
. This can be the host in plain text or the name of an ENVIRONMENT VARIABLE. - Set the
port
to the port number the database is listening for connections on. This can be any valid port number. - Set the
username
to the database username the server should use to authenticate itself against your chosen database. This can be the username in plain text or the name of an ENVIRONMENT VARIABLE. - Set the
password
to the database password the server should use to authenticate itself against your chosen database. This can be the password in plain text or an ENVIRONMENT VARIABLE. For example:admin
orPOSTGRES_PASSWORD
- Set the
databaseName
to the name of the database you want the OpenApi to be generated from. This can be the name of the database in plain text or the name of an ENVIRONMENT VARIABLE. - Run the steps in the Installation section and set the
-Dproject.config=
argument to the path of theconfig.json
file you just create.
- Set the
- Create a config.json file. You can use the file in
docker/config.json
as a base. - Update the
cockroachApi
object.- Set the
enabled
property totrue
- Set the
host
to the address the HTTP Server should attach to. This can belocalhost
or0.0.0.0
orsome.address.com
. - Set the
port
to the port number the HTTP Server should listen for connection on. This can be any valid port number. - Set the
openApiFilePath
to where you want the OpenApi file generated to be stored. For example:./crbOpenApi.yaml
- Now the
database
object holds configuration regarding the database we are trying base of our API from. - Set the
host
to the address of the database. For example:localhost
or0.0.0.0
orsome.address.com
. This can be the host in plain text or the name of an ENVIRONMENT VARIABLE. - Set the
port
to the port number the database is listening for connections on. This can be any valid port number. - Set the
username
to the database username the server should use to authenticate itself against your chosen database. This can be the username in plain text or the name of an ENVIRONMENT VARIABLE. - Set the
password
to the database password the server should use to authenticate itself against your chosen database. This can be the password in plain text or an ENVIRONMENT VARIABLE. For example:admin
orCOCKROACH_PASSWORD
- Set the
databaseName
to the name of the database you want the OpenApi to be generated from. This can be the name of the database in plain text or the name of an ENVIRONMENT VARIABLE. - Run the steps in the Installation section and set the
-Dproject.config=
argument to the path of theconfig.json
file you just create.
- Set the
There is a working example in the docker
folder on how to integrate in a docker-compose file.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
MIT License
Copyright (c) 2021 Dercio Daio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.