web_plsql 1.3.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -166
- package/dist/chunk-CfYAbeIz.mjs +13 -0
- package/dist/frontend/assets/main-B5q2ur8E.js +147 -0
- package/dist/frontend/assets/main-B5q2ur8E.js.br +0 -0
- package/dist/frontend/assets/main-B5q2ur8E.js.gz +0 -0
- package/dist/frontend/assets/main-CoERzZAr.css +1 -0
- package/dist/frontend/assets/main-CoERzZAr.css.br +0 -0
- package/dist/frontend/assets/main-CoERzZAr.css.gz +0 -0
- package/dist/frontend/index.html +2 -2
- package/dist/frontend/index.html.br +0 -0
- package/dist/frontend/index.html.gz +0 -0
- package/dist/index.d.mts +25 -12
- package/dist/index.mjs +34 -180
- package/dist/index.mjs.map +1 -1
- package/dist/{oracledb-mock-Dn8aHtd7.mjs → oracledb-mock-Cya43xKB.mjs} +3 -4
- package/dist/oracledb-mock-Cya43xKB.mjs.map +1 -0
- package/package.json +45 -48
- package/dist/chunk-DQk6qfdC.mjs +0 -18
- package/dist/frontend/assets/main-D2PlS0b8.js +0 -147
- package/dist/frontend/assets/main-D2PlS0b8.js.br +0 -0
- package/dist/frontend/assets/main-D2PlS0b8.js.gz +0 -0
- package/dist/frontend/assets/main-bU4x_yEW.css +0 -1
- package/dist/frontend/assets/main-bU4x_yEW.css.br +0 -0
- package/dist/frontend/assets/main-bU4x_yEW.css.gz +0 -0
- package/dist/oracledb-mock-Dn8aHtd7.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
# Oracle PL/SQL Gateway Middleware for the Express web framework for Node.js
|
|
7
7
|
This Express Middleware is a bridge between a PL/SQL application running in an Oracle Database and an Express web server for Node.js.
|
|
8
|
-
It is an open-source alternative to mod_plsql
|
|
9
|
-
|
|
10
|
-
and serve the content using the Express web framework for Node.js.
|
|
8
|
+
It is an open-source alternative to the legacy **mod_plsql**, the Embedded PL/SQL Gateway, and the modern **Oracle REST Data Services (ORDS)** (specifically its PL/SQL Gateway mode).
|
|
9
|
+
|
|
10
|
+
It allows you to develop PL/SQL web applications using the PL/SQL Web Toolkit (OWA) and serve the content using the Express web framework for Node.js.
|
|
11
11
|
|
|
12
12
|
Please feel free to try and suggest any improvements. Your thoughts and ideas are most welcome.
|
|
13
13
|
|
|
@@ -64,148 +64,14 @@ There are 2 options on how to use the web_plsql express middleware:
|
|
|
64
64
|
|
|
65
65
|
## Use the predefined `startServer` function
|
|
66
66
|
|
|
67
|
-
The `startServer`
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
/**
|
|
71
|
-
* @typedef {'basic' | 'debug'} errorStyleType
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @typedef {object} configStaticType
|
|
76
|
-
* @property {string} route - The Static route path.
|
|
77
|
-
* @property {string} directoryPath - The Static directory.
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @typedef {(connection: Connection, procedure: string) => void | Promise<void>} transactionCallbackType
|
|
82
|
-
* @typedef {'commit' | 'rollback' | transactionCallbackType | undefined | null} transactionModeType
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* @typedef {object} configPlSqlHandlerType
|
|
87
|
-
* @property {string} defaultPage - The default page.
|
|
88
|
-
* @property {string} [pathAlias] - The path alias.
|
|
89
|
-
* @property {string} [pathAliasProcedure] - The path alias.
|
|
90
|
-
* @property {string} documentTable - The document table.
|
|
91
|
-
* @property {string[]} [exclusionList] - The exclusion list.
|
|
92
|
-
* @property {string} [requestValidationFunction] - The request validation function.
|
|
93
|
-
* @property {Record<string, string>} [cgi] - The additional CGI.
|
|
94
|
-
* @property {transactionModeType} [transactionMode='commit'] - Specifies an optional transaction mode.
|
|
95
|
-
* "commit" this automatically commits any open transaction after each request. This is the defaults because this is what mod_plsql and ohs are doing.
|
|
96
|
-
* "rollback" this automatically rolles back any open transaction after each request.
|
|
97
|
-
* "transactionCallbackType" this allows to defined a custom handler as a JavaScript function.
|
|
98
|
-
* @property {errorStyleType} errorStyle - The error style.
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @typedef {object} configPlSqlConfigType
|
|
103
|
-
* @property {string} route - The PL/SQL route path.
|
|
104
|
-
* @property {string} user - The Oracle username.
|
|
105
|
-
* @property {string} password - The Oracle password.
|
|
106
|
-
* @property {string} connectString - The Oracle connect string.
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @typedef {configPlSqlHandlerType & configPlSqlConfigType} configPlSqlType
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* @typedef {object} configType
|
|
115
|
-
* @property {number} port - The server port number.
|
|
116
|
-
* @property {configAdminType} [admin] - The admin console configuration.
|
|
117
|
-
* @property {configStaticType[]} routeStatic - The static routes.
|
|
118
|
-
* @property {configPlSqlType[]} routePlSql - The PL/SQL routes.
|
|
119
|
-
* @property {number} [uploadFileSizeLimit] - Maximum size of each uploaded file in bytes or no limit if omitted.
|
|
120
|
-
* @property {string} loggerFilename - name of the request logger filename or '' if not required.
|
|
121
|
-
*/
|
|
122
|
-
```
|
|
67
|
+
The `startServer` API uses a `configType` configuration object. You can review the complete type definitions in the source code:
|
|
68
|
+
[src/backend/types.ts](https://github.com/doberkofler/web_plsql/blob/master/src/backend/types.ts)
|
|
123
69
|
|
|
124
70
|
## Hand Craft Express Server with Composable Middleware
|
|
125
71
|
|
|
126
|
-
web_plsql exports composable middleware components that can be integrated into any Express application.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
For full control over your Express application with PL/SQL routes and admin console:
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
import express from 'express';
|
|
134
|
-
import path from 'path';
|
|
135
|
-
import {
|
|
136
|
-
handlerWebPlSql,
|
|
137
|
-
handlerAdminConsole,
|
|
138
|
-
AdminContext,
|
|
139
|
-
oracledb,
|
|
140
|
-
type configType,
|
|
141
|
-
type PoolCacheEntry,
|
|
142
|
-
} from 'web_plsql';
|
|
143
|
-
|
|
144
|
-
(async () => {
|
|
145
|
-
const app = express();
|
|
146
|
-
|
|
147
|
-
// 1. Define configuration
|
|
148
|
-
const config: configType = {
|
|
149
|
-
port: 8080,
|
|
150
|
-
routeStatic: [],
|
|
151
|
-
routePlSql: [{
|
|
152
|
-
route: '/myapp',
|
|
153
|
-
user: 'sample',
|
|
154
|
-
password: 'sample',
|
|
155
|
-
connectString: 'localhost:1521/ORCL',
|
|
156
|
-
defaultPage: 'myapp.home',
|
|
157
|
-
documentTable: 'doctable',
|
|
158
|
-
errorStyle: 'debug',
|
|
159
|
-
}],
|
|
160
|
-
uploadFileSizeLimit: 50 * 1024 * 1024,
|
|
161
|
-
loggerFilename: 'access.log',
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// 2. Create Oracle connection pool
|
|
165
|
-
const pool = await oracledb.createPool({
|
|
166
|
-
user: config.routePlSql[0].user,
|
|
167
|
-
password: config.routePlSql[0].password,
|
|
168
|
-
connectString: config.routePlSql[0].connectString,
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// 3. Create PL/SQL handler
|
|
172
|
-
const plsqlHandler = handlerWebPlSql(pool, {
|
|
173
|
-
defaultPage: config.routePlSql[0].defaultPage,
|
|
174
|
-
documentTable: config.routePlSql[0].documentTable,
|
|
175
|
-
errorStyle: config.routePlSql[0].errorStyle,
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
// 4. Create AdminContext (required for admin console)
|
|
179
|
-
const caches: PoolCacheEntry[] = [{
|
|
180
|
-
poolName: config.routePlSql[0].route,
|
|
181
|
-
procedureNameCache: plsqlHandler.procedureNameCache,
|
|
182
|
-
argumentCache: plsqlHandler.argumentCache,
|
|
183
|
-
}];
|
|
184
|
-
const adminContext = new AdminContext(config, [pool], caches);
|
|
185
|
-
|
|
186
|
-
// 5. Mount PL/SQL handler with stats tracking
|
|
187
|
-
app.use(config.routePlSql[0].route, (req, res, next) => {
|
|
188
|
-
const start = process.hrtime();
|
|
189
|
-
res.on('finish', () => {
|
|
190
|
-
const [s, ns] = process.hrtime(start);
|
|
191
|
-
adminContext.statsManager.recordRequest(s * 1000 + ns / 1e6, res.statusCode >= 400);
|
|
192
|
-
});
|
|
193
|
-
plsqlHandler(req, res, next);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
// 6. Mount admin console
|
|
197
|
-
app.use('/admin', handlerAdminConsole({
|
|
198
|
-
staticDir: path.join(__dirname, 'node_modules/web_plsql/dist/frontend'),
|
|
199
|
-
user: 'admin',
|
|
200
|
-
password: 'secret',
|
|
201
|
-
}, adminContext));
|
|
202
|
-
|
|
203
|
-
// 7. Start server
|
|
204
|
-
app.listen(config.port, () => {
|
|
205
|
-
console.log(`Server running on port ${config.port}`);
|
|
206
|
-
});
|
|
207
|
-
})();
|
|
208
|
-
```
|
|
72
|
+
The web_plsql API exports composable middleware components that can be integrated into any Express application.
|
|
73
|
+
Start by having a look at the build-in server code:
|
|
74
|
+
[src/backend/server/server.ts](https://github.com/doberkofler/web_plsql/blob/master/src/backend/server/server.ts)
|
|
209
75
|
|
|
210
76
|
### AdminContext Requirement
|
|
211
77
|
|
|
@@ -220,6 +86,49 @@ const adminContext = new AdminContext(config, pools, caches);
|
|
|
220
86
|
app.use('/admin', handlerAdminConsole(config, adminContext));
|
|
221
87
|
```
|
|
222
88
|
|
|
89
|
+
# Compare with Oracle REST Data Services (ORDS)
|
|
90
|
+
|
|
91
|
+
`web_plsql` is a specialized, lightweight alternative to ORDS for scenarios where only the **PL/SQL Gateway** functionality is required.
|
|
92
|
+
|
|
93
|
+
| Feature | web_plsql | Oracle REST Data Services (ORDS) |
|
|
94
|
+
| :--- | :--- | :--- |
|
|
95
|
+
| **Primary Goal** | Focused, high-performance PL/SQL Gateway | Full REST platform and PL/SQL Gateway |
|
|
96
|
+
| **Technology** | Node.js (V8 engine) | Java (JVM) |
|
|
97
|
+
| **Deployment** | Lightweight, Docker-native | Requires Jetty/Tomcat or WebLogic |
|
|
98
|
+
| **Configuration** | Modern JSON / Environment Variables | XML files and Database Metadata |
|
|
99
|
+
| **Monitoring** | Built-in real-time SPA Admin Console | SQL Developer or separate OCI monitoring |
|
|
100
|
+
| **Caching** | Efficient LFU (Least Frequently Used) memory cache | Java-based metadata and result caching |
|
|
101
|
+
|
|
102
|
+
The following ORDS configuration (typically found in `conf/ords/defaults.xml` or `settings.xml`) translates to the `web_plsql` configuration options as follows:
|
|
103
|
+
|
|
104
|
+
**ORDS**
|
|
105
|
+
```xml
|
|
106
|
+
<entry key="db.username">sample</entry>
|
|
107
|
+
<entry key="db.password">sample</entry>
|
|
108
|
+
<entry key="db.hostname">localhost</entry>
|
|
109
|
+
<entry key="db.port">1521</entry>
|
|
110
|
+
<entry key="db.servicename">ORCL</entry>
|
|
111
|
+
<entry key="misc.defaultPage">sample_pkg.page_index</entry>
|
|
112
|
+
<entry key="security.requestValidationFunction">sample_pkg.request_validation_function</entry>
|
|
113
|
+
<entry key="owa.docTable">LJP_Documents</entry>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**web_plsql**
|
|
117
|
+
```typescript
|
|
118
|
+
{
|
|
119
|
+
routePlSql: [
|
|
120
|
+
{
|
|
121
|
+
user: 'sample', // db.username
|
|
122
|
+
password: 'sample', // db.password
|
|
123
|
+
connectString: 'localhost:1521/ORCL', // db.hostname, db.port, db.servicename
|
|
124
|
+
defaultPage: 'sample_pkg.page_index', // misc.defaultPage
|
|
125
|
+
requestValidationFunction: 'sample_pkg.request_validation_function', // security.requestValidationFunction
|
|
126
|
+
documentTable: 'LJP_Documents', // owa.docTable
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
223
132
|
# Compare with mod_plsql
|
|
224
133
|
|
|
225
134
|
The following mod_plsql DAD configuration translates to the configuration options as follows:
|
|
@@ -244,7 +153,7 @@ The following mod_plsql DAD configuration translates to the configuration option
|
|
|
244
153
|
</Location>
|
|
245
154
|
```
|
|
246
155
|
|
|
247
|
-
**
|
|
156
|
+
**web_plsql**
|
|
248
157
|
```typescript
|
|
249
158
|
{
|
|
250
159
|
port: 80,
|
|
@@ -275,12 +184,16 @@ The following mod_plsql DAD configuration translates to the configuration option
|
|
|
275
184
|
}
|
|
276
185
|
```
|
|
277
186
|
|
|
278
|
-
## Create a custom Express application based on the default server implemented in `src/backend/server/server.ts`.
|
|
279
|
-
|
|
280
|
-
...
|
|
281
|
-
|
|
282
187
|
# Configuration options
|
|
283
188
|
|
|
189
|
+
## Supported ORDS configuration options
|
|
190
|
+
- db.username -> routePlSql[].user
|
|
191
|
+
- db.password -> routePlSql[].password
|
|
192
|
+
- db.hostname, db.port, db.servicename -> routePlSql[].connectString
|
|
193
|
+
- misc.defaultPage -> routePlSql[].defaultPage
|
|
194
|
+
- security.requestValidationFunction -> routePlSql[].requestValidationFunction
|
|
195
|
+
- owa.docTable -> routePlSql[].documentTable
|
|
196
|
+
|
|
284
197
|
## Supported mod_plsql configuration options
|
|
285
198
|
- PlsqlDatabaseConnectString -> routePlSql[].connectString
|
|
286
199
|
- PlsqlDatabaseUserName -> routePlSql[].user
|
|
@@ -292,33 +205,56 @@ The following mod_plsql DAD configuration translates to the configuration option
|
|
|
292
205
|
- PlsqlLogDirectory -> loggerFilename
|
|
293
206
|
- PlsqlPathAlias -> routePlSql[].pathAlias
|
|
294
207
|
- PlsqlPathAliasProcedure -> routePlSql[].pathAliasProcedure
|
|
295
|
-
-
|
|
296
|
-
-
|
|
297
|
-
- PlsqlExclusionList
|
|
208
|
+
- PlsqlRequestValidationFunction -> routePlSql[].requestValidationFunction
|
|
209
|
+
- PlsqlExclusionList -> routePlSql[].exclusionList
|
|
298
210
|
- Basic and custom authentication methods, based on the OWA_SEC package and custom packages.
|
|
299
211
|
- Caching of procedure metadata and validation results for high performance.
|
|
300
212
|
- Real-time monitoring and management via a built-in Admin Console.
|
|
301
213
|
|
|
302
|
-
##
|
|
214
|
+
## Options that are only available in web_plsql
|
|
303
215
|
- The option `transactionModeType` specifies an optional transaction mode.
|
|
304
216
|
"commit" this automatically commits any open transaction after each request. This is the defaults because this is what mod_plsql and ohs are doing.
|
|
305
217
|
"rollback" this automatically rolls back any open transaction after each request.
|
|
306
218
|
"transactionCallbackType" this allows defining a custom handler as a JavaScript function.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
219
|
+
- The option `auth` allows for custom authentication strategies.
|
|
220
|
+
- The option `setupExtensions` allows for injecting custom Express routes and middleware.
|
|
221
|
+
This hook is executed after the database connection pools are initialized but before the static file routes and SPA fallback are mounted.
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
setupExtensions: async (app, pools) => {
|
|
225
|
+
// app is the Express application
|
|
226
|
+
// pools is an array of initialized Oracle connection pools
|
|
227
|
+
app.get('/api-ext/test', (req, res) => {
|
|
228
|
+
res.json({ status: 'ok', poolsCount: pools.length });
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Basic Authentication**:
|
|
234
|
+
```typescript
|
|
235
|
+
auth: {
|
|
236
|
+
type: 'basic',
|
|
237
|
+
callback: async (credentials, pool) => {
|
|
238
|
+
// validate credentials against database or other source
|
|
239
|
+
// return username string if valid, null if invalid
|
|
240
|
+
return isValid ? credentials.username : null;
|
|
241
|
+
},
|
|
242
|
+
realm: 'My Realm' // optional
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Custom Authentication**:
|
|
247
|
+
```typescript
|
|
248
|
+
auth: {
|
|
249
|
+
type: 'custom',
|
|
250
|
+
callback: async (req, pool) => {
|
|
251
|
+
// inspect request (headers, cookies, etc)
|
|
252
|
+
// return username string if valid, null if invalid
|
|
253
|
+
const token = req.headers.authorization;
|
|
254
|
+
return validateToken(token) ? 'user' : null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
322
258
|
|
|
323
259
|
|
|
324
260
|
# License
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|