https://github.com/tsmx/oracle-rest-get
A configurable service creating a read-only REST-API (GET) for an Oracle Database scheme.
https://github.com/tsmx/oracle-rest-get
api oracle-db rest
Last synced: 9 months ago
JSON representation
A configurable service creating a read-only REST-API (GET) for an Oracle Database scheme.
- Host: GitHub
- URL: https://github.com/tsmx/oracle-rest-get
- Owner: tsmx
- License: mit
- Created: 2019-01-07T18:48:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-30T20:15:15.000Z (over 1 year ago)
- Last Synced: 2025-03-01T04:44:14.831Z (over 1 year ago)
- Topics: api, oracle-db, rest
- Language: JavaScript
- Homepage:
- Size: 1010 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# oracle-rest-get
A simple example for creating configurable readonly GET REST-endpoints for data in an Oracle DB tables or views using [oracledb](https://www.npmjs.com/package/oracledb).
## Configuration setup
```json
{
"dbconfig": {
"user": "test",
"password": "test",
"connectString": "localhost/xepdb1"
},
"entities": [
{
"url": "/storage",
"tablename": "STORAGE",
"id": "ID"
},
{
"url": "/contract",
"tablename": "CONTRACT",
"id": "ID"
}
]
}
```
## Routes
The sample code/config dynamically registers the following routes under `localhost:3000` to have a basic REST API for data retrieval:
```
GET /storage
GET /storage/:id
GET /contract
GET /contract/:id
```
Queries the respective tables and returns the result-set as an array of JSON objects.
## Pre-requisites
- A locally installed Oracle XE 18c with user `test` in the container `XEPDB1`.
- Oracle libraries registered with `ldconfig`. To do so, as root:
- Add path to the libs to `/etc/ld.so.conf` directly or create a new conf file under `/etc/ld.so.conf.d`
- Run `ldconfig`
- E.g. assuming Oracle was installed in `/opt/oracle`:
```bash
$ echo "/opt/oracle/product/18c/dbhomeXE/lib" > /etc/ld.so.conf.d/oracle-xe-18c.conf
$ ldconfig
```
## Considerations before production use
The provided code is a first step to get a read-only REST interface up & running for an Oracle DB. Before using it in production you should at least consider the following points:
- Securing the configuration where sensible data is currently stored as plain text. For that I recommend my project [secure-config](https://www.npmjs.com/package/@tsmx/secure-config).
- Adding filter functionality to the list retrieval methods, e.g. as query strings. Also here have a closer look on security as passed values will have to make it to your queries.
- Take care about compound keys if needed.
- Be sure that the provided DB user only has read rights on the objects (tables/views) he really needs.