web_plsql 0.8.0 → 0.10.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 +22 -9
- package/examples/{server_apex.js → config-apex.js} +1 -1
- package/examples/config-docker.js +31 -0
- package/examples/config-docker.json +26 -0
- package/examples/{server_sample.js → config-native.js} +3 -3
- package/examples/sql/install.sql +3 -3
- package/package.json +25 -24
- package/src/procedureSanitize.js +1 -1
- package/src/server.js +62 -18
- package/src/trace.js +1 -1
- package/src/types.js +30 -35
- package/types/server.d.ts +3 -0
- package/types/stream.d.ts +1 -0
- package/types/trace.d.ts +1 -0
- package/types/types.d.ts +68 -6
package/README.md
CHANGED
|
@@ -24,21 +24,28 @@ Please visit the [node-oracledb](https://node-oracledb.readthedocs.io/en/latest/
|
|
|
24
24
|
* Create a new npm project (`npm i`)
|
|
25
25
|
* Install package (`npm i --omit=dev web_plsql`)
|
|
26
26
|
|
|
27
|
-
# Example
|
|
27
|
+
# Example
|
|
28
|
+
|
|
29
|
+
## Native
|
|
28
30
|
* Change to the `examples/sql` directory, start SQLPLus, connect to the database as SYS specifying the SYSDBA roleInstall and install the sample schema `@examples/sql/install.sql`.
|
|
29
|
-
* Start server using `node examples/
|
|
31
|
+
* Start server using `node examples/config-native.js` after having set the WEB_PLSQL_ORACLE_SERVER environment variable to the database where you just installed the sample schema.
|
|
30
32
|
* Invoke a browser and open the page `http://localhost/sample`.
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
* Build the image using `npm run image-build
|
|
34
|
-
*
|
|
34
|
+
## Container
|
|
35
|
+
* Build the image using `npm run image-build`.
|
|
36
|
+
* Adapt the `examples/config-docker.json` configuration file. Typically only the `connectString` property must be changed.
|
|
37
|
+
* Start the container using `docker compose up -d`.
|
|
38
|
+
|
|
39
|
+
# Configuration
|
|
40
|
+
|
|
41
|
+
There are 2 options on how to use the web_plsql express middleware:
|
|
42
|
+
- Use the predefined `startHttpServer` api in `src/server.js` like in the `examples/config-native.js` example
|
|
43
|
+
- Hand craft a new Express server using the `handlerWebPlSql` middleware in `src/handlerPlSql.js`
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
There are 2 main options on how to use the mod_plsql Express middleware:
|
|
45
|
+
## Use the predefined `startHttpServer`
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
The `startHttpServer` api uses the following configuration object:
|
|
40
48
|
|
|
41
|
-
The the default server implemented in `src/server.js` and has the following configuration options:
|
|
42
49
|
```
|
|
43
50
|
/**
|
|
44
51
|
* @typedef {'basic' | 'debug'} errorStyleType
|
|
@@ -77,6 +84,12 @@ export const z$errorStyleType = z.enum(['basic', 'debug']);
|
|
|
77
84
|
*/
|
|
78
85
|
```
|
|
79
86
|
|
|
87
|
+
## Hand craft a new Express server using the `handlerWebPlSql` middleware
|
|
88
|
+
|
|
89
|
+
WIP
|
|
90
|
+
|
|
91
|
+
# Compare with mod_plsql
|
|
92
|
+
|
|
80
93
|
The following mod_plsql DAD configuration translates to the configuration options as follows:
|
|
81
94
|
|
|
82
95
|
**DAD**
|
|
@@ -13,7 +13,7 @@ void startHttpServer({
|
|
|
13
13
|
route: '/apex',
|
|
14
14
|
user: 'APEX_PUBLIC_USER',
|
|
15
15
|
password: 'secret',
|
|
16
|
-
connectString:
|
|
16
|
+
connectString: 'localhost:1521/orcl',
|
|
17
17
|
defaultPage: 'apex',
|
|
18
18
|
pathAlias: 'r',
|
|
19
19
|
pathAliasProcedure: 'wwv_flow.resolve_friendly_url',
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// @ts-expect-error NOTE: the following import would show an error because the path does not exist
|
|
4
|
+
import {startHttpServer} from './src/index.js';
|
|
5
|
+
|
|
6
|
+
void startHttpServer({
|
|
7
|
+
port: 8888,
|
|
8
|
+
routeStatic: [
|
|
9
|
+
{
|
|
10
|
+
route: '/static',
|
|
11
|
+
directoryPath: 'examples/static',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
routePlSql: [
|
|
15
|
+
{
|
|
16
|
+
route: '/sample',
|
|
17
|
+
user: 'sample', // PlsqlDatabaseUserName
|
|
18
|
+
password: 'sample', // PlsqlDatabasePassword
|
|
19
|
+
connectString: 'host.docker.internal:1521/TEST', // PlsqlDatabaseConnectString
|
|
20
|
+
defaultPage: 'sample_pkg.page_index', // PlsqlDefaultPage
|
|
21
|
+
documentTable: 'doctable', // PlsqlDocumentTablename
|
|
22
|
+
exclusionList: ['sample_pkg.page_exclusion_list'], // PlsqlExclusionList
|
|
23
|
+
requestValidationFunction: 'sample_pkg.request_validation_function', // PlsqlRequestValidationFunction
|
|
24
|
+
pathAlias: 'myalias', // PlsqlPathAlias
|
|
25
|
+
pathAliasProcedure: 'sample_pkg.page_path_alias', // PlsqlPathAliasProcedure
|
|
26
|
+
errorStyle: 'debug', // PlsqlErrorStyle
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
loggerFilename: 'access.log', // PlsqlLogEnable and PlsqlLogDirectory
|
|
30
|
+
monitorConsole: false,
|
|
31
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"port": 8888,
|
|
3
|
+
"routeStatic": [
|
|
4
|
+
{
|
|
5
|
+
"route": "/static",
|
|
6
|
+
"directoryPath": "examples/static"
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"routePlSql": [
|
|
10
|
+
{
|
|
11
|
+
"route": "/sample",
|
|
12
|
+
"user": "sample",
|
|
13
|
+
"password": "sample",
|
|
14
|
+
"connectString": "host.docker.internal:1521/TEST",
|
|
15
|
+
"defaultPage": "sample_pkg.page_index",
|
|
16
|
+
"documentTable": "doctable",
|
|
17
|
+
"exclusionList": ["sample_pkg.page_exclusion_list"],
|
|
18
|
+
"requestValidationFunction": "sample_pkg.request_validation_function",
|
|
19
|
+
"pathAlias": "myalias",
|
|
20
|
+
"pathAliasProcedure": "sample_pkg.page_path_alias",
|
|
21
|
+
"errorStyle": "debug"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"loggerFilename": "access.log",
|
|
25
|
+
"monitorConsole": false
|
|
26
|
+
}
|
|
@@ -13,9 +13,9 @@ void startHttpServer({
|
|
|
13
13
|
routePlSql: [
|
|
14
14
|
{
|
|
15
15
|
route: '/sample',
|
|
16
|
-
user:
|
|
17
|
-
password:
|
|
18
|
-
connectString: process.env.WEB_PLSQL_ORACLE_SERVER ?? 'localhost:1521/
|
|
16
|
+
user: 'sample', // PlsqlDatabaseUserName
|
|
17
|
+
password: 'sample', // PlsqlDatabasePassword
|
|
18
|
+
connectString: process.env.WEB_PLSQL_ORACLE_SERVER ?? 'localhost:1521/TEST', // PlsqlDatabaseConnectString
|
|
19
19
|
defaultPage: 'sample_pkg.page_index', // PlsqlDefaultPage
|
|
20
20
|
documentTable: 'doctable', // PlsqlDocumentTablename
|
|
21
21
|
exclusionList: ['sample_pkg.page_exclusion_list'], // PlsqlExclusionList
|
package/examples/sql/install.sql
CHANGED
|
@@ -19,10 +19,10 @@ GRANT execute on dbms_lob TO &&SAMPLE_USER;
|
|
|
19
19
|
ALTER SESSION SET CURRENT_SCHEMA=&&SAMPLE_USER;
|
|
20
20
|
|
|
21
21
|
-- install document table
|
|
22
|
-
|
|
22
|
+
@@doctable.sql
|
|
23
23
|
|
|
24
24
|
-- install package
|
|
25
|
-
|
|
25
|
+
@@sample_package.sql
|
|
26
26
|
show errors
|
|
27
|
-
|
|
27
|
+
@@sample_package_body.sql
|
|
28
28
|
show errors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web_plsql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"author": "Dieter Oberkofler <dieter.oberkofler@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "The Express Middleware for Oracle PL/SQL",
|
|
@@ -43,52 +43,53 @@
|
|
|
43
43
|
"types": "./types/index.d.ts",
|
|
44
44
|
"type": "module",
|
|
45
45
|
"scripts": {
|
|
46
|
-
"lint": "prettier --check . && eslint . && tsc --noEmit",
|
|
46
|
+
"lint": "prettier --check --experimental-cli . && eslint . && tsc --noEmit",
|
|
47
47
|
"test": "node --test --test-concurrency=1 \"./tests/**/*.test.js\"",
|
|
48
|
-
"types": "rm -rf types && tsc --noEmit false --declaration true --declarationDir types --emitDeclarationOnly true --allowJs true --target es2020 --module es2020 --moduleResolution node src/*.js",
|
|
48
|
+
"types": "rm -rf types && tsc --noEmit false --declaration true --declarationDir types --emitDeclarationOnly true --allowJs true --target es2020 --module es2020 --moduleResolution node --allowSyntheticDefaultImports true src/*.js",
|
|
49
49
|
"clean": "shx rm -f *.tgz && shx rm -f *.log",
|
|
50
50
|
"ci": "npm run clean && npm run lint && npm run test",
|
|
51
51
|
"create-package": "shx rm -f *.tgz && npm pack",
|
|
52
52
|
"image-build": "docker build --no-cache --progress=plain --tag=web_plsql .",
|
|
53
53
|
"image-save": "docker save web_plsql | gzip > web_plsql.tar.gz"
|
|
54
54
|
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"oracledb": "6.9.0"
|
|
57
|
+
},
|
|
55
58
|
"dependencies": {
|
|
56
59
|
"basic-auth": "2.0.1",
|
|
57
60
|
"body-parser": "2.2.0",
|
|
58
|
-
"compression": "1.8.
|
|
59
|
-
"connect-multiparty": "2.2.0",
|
|
61
|
+
"compression": "1.8.1",
|
|
60
62
|
"cookie-parser": "1.4.7",
|
|
61
|
-
"debug": "4.4.
|
|
63
|
+
"debug": "4.4.1",
|
|
62
64
|
"escape-html": "1.0.3",
|
|
63
65
|
"express": "5.1.0",
|
|
64
|
-
"fs-extra": "11.3.
|
|
66
|
+
"fs-extra": "11.3.1",
|
|
65
67
|
"http-parser-js": "0.5.10",
|
|
66
|
-
"morgan": "1.10.
|
|
67
|
-
"multer": "
|
|
68
|
-
"oracledb": "6.8.0",
|
|
68
|
+
"morgan": "1.10.1",
|
|
69
|
+
"multer": "2.0.2",
|
|
69
70
|
"rotating-file-stream": "3.2.6",
|
|
70
|
-
"zod": "
|
|
71
|
+
"zod": "4.0.17"
|
|
71
72
|
},
|
|
72
73
|
"devDependencies": {
|
|
73
74
|
"@types/basic-auth": "1.1.8",
|
|
74
|
-
"@types/body-parser": "1.19.
|
|
75
|
-
"@types/compression": "1.
|
|
76
|
-
"@types/cookie-parser": "1.4.
|
|
75
|
+
"@types/body-parser": "1.19.6",
|
|
76
|
+
"@types/compression": "1.8.1",
|
|
77
|
+
"@types/cookie-parser": "1.4.9",
|
|
77
78
|
"@types/debug": "4.1.12",
|
|
78
79
|
"@types/escape-html": "1.0.4",
|
|
79
80
|
"@types/fs-extra": "11.0.4",
|
|
80
|
-
"@types/morgan": "1.9.
|
|
81
|
-
"@types/multer": "
|
|
82
|
-
"@types/node": "
|
|
83
|
-
"@types/oracledb": "6.
|
|
81
|
+
"@types/morgan": "1.9.10",
|
|
82
|
+
"@types/multer": "2.0.0",
|
|
83
|
+
"@types/node": "24.3.0",
|
|
84
|
+
"@types/oracledb": "6.9.1",
|
|
84
85
|
"@types/supertest": "6.0.3",
|
|
85
|
-
"eslint": "9.
|
|
86
|
-
"eslint-plugin-jsdoc": "
|
|
87
|
-
"prettier": "3.
|
|
86
|
+
"eslint": "9.33.0",
|
|
87
|
+
"eslint-plugin-jsdoc": "54.1.0",
|
|
88
|
+
"prettier": "3.6.2",
|
|
88
89
|
"rimraf": "6.0.1",
|
|
89
90
|
"shx": "0.4.0",
|
|
90
|
-
"supertest": "7.1.
|
|
91
|
-
"typescript": "5.
|
|
92
|
-
"typescript-eslint": "8.
|
|
91
|
+
"supertest": "7.1.4",
|
|
92
|
+
"typescript": "5.9.2",
|
|
93
|
+
"typescript-eslint": "8.39.1"
|
|
93
94
|
}
|
|
94
95
|
}
|
package/src/procedureSanitize.js
CHANGED
|
@@ -135,7 +135,7 @@ const loadRequestValid = async (procName, requestValidationFunction, databaseCon
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
try {
|
|
138
|
-
const data = z.
|
|
138
|
+
const data = z.strictObject({valid: z.number()}).parse(result.outBinds);
|
|
139
139
|
return data.valid === 1;
|
|
140
140
|
} catch (err) {
|
|
141
141
|
debug('result', result.outBinds);
|
package/src/server.js
CHANGED
|
@@ -28,6 +28,54 @@ import {readFileSyncUtf8, getJsonFile} from './file.js';
|
|
|
28
28
|
* @typedef {import('./types.js').configType} configType
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Show configuration.
|
|
33
|
+
* @param {configType} config - The config.
|
|
34
|
+
* @returns {void}
|
|
35
|
+
*/
|
|
36
|
+
export const showConfig = (config) => {
|
|
37
|
+
const expressVersion = getExpressVersion();
|
|
38
|
+
const packageVersion = getPackageVersion();
|
|
39
|
+
|
|
40
|
+
console.log('-'.repeat(80));
|
|
41
|
+
console.log('NODE PL/SQL SERVER');
|
|
42
|
+
console.log('-'.repeat(80));
|
|
43
|
+
|
|
44
|
+
console.log(`Application version: ${packageVersion}`);
|
|
45
|
+
console.log(`Express version: ${expressVersion}`);
|
|
46
|
+
console.log(`Server port: ${config.port}`);
|
|
47
|
+
console.log(`Access log: ${config.loggerFilename.length > 0 ? config.loggerFilename : ''}`);
|
|
48
|
+
console.log(`Monitor console: ${config.monitorConsole ? 'on' : 'off'}`);
|
|
49
|
+
|
|
50
|
+
if (config.routeStatic.length > 0) {
|
|
51
|
+
console.log('');
|
|
52
|
+
config.routeStatic.forEach((e, i) => {
|
|
53
|
+
console.log(`Static route #${i + 1}`);
|
|
54
|
+
console.log(` Route: "${e.route}"`);
|
|
55
|
+
console.log(` Directory path: "${e.directoryPath}"`);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (config.routePlSql.length > 0) {
|
|
60
|
+
console.log('');
|
|
61
|
+
config.routePlSql.forEach((e, i) => {
|
|
62
|
+
console.log(`Application route #${i + 1}`);
|
|
63
|
+
console.log(` Route: "http://localhost:${config.port}${e.route}"`);
|
|
64
|
+
console.log(` Oracle user: "${e.user}"`);
|
|
65
|
+
console.log(` Oracle server: "${e.connectString}"`);
|
|
66
|
+
console.log(` Oracle document table: "${e.documentTable}"`);
|
|
67
|
+
console.log(` Default page: "${e.defaultPage}"`);
|
|
68
|
+
console.log(` Path alias: "${e.pathAlias}"`);
|
|
69
|
+
console.log(` Path alias procedure: "${e.pathAliasProcedure}"`);
|
|
70
|
+
console.log(` Exclution list: "${e.exclusionList?.join(', ')}"`);
|
|
71
|
+
console.log(` Request validation function: "${e.requestValidationFunction}"`);
|
|
72
|
+
console.log(` Error style: "${e.errorStyle}"`);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
console.log('-'.repeat(80));
|
|
77
|
+
};
|
|
78
|
+
|
|
31
79
|
/**
|
|
32
80
|
* Create HTTP server.
|
|
33
81
|
* @param {Express} app - express application
|
|
@@ -38,7 +86,6 @@ import {readFileSyncUtf8, getJsonFile} from './file.js';
|
|
|
38
86
|
export const createHttpServer = (app, port, connectionPools) => {
|
|
39
87
|
return new Promise((resolve) => {
|
|
40
88
|
// Create server
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
42
89
|
const server = http.createServer({}, app);
|
|
43
90
|
|
|
44
91
|
// Install shutdown handler
|
|
@@ -73,7 +120,6 @@ export const createHttpsServer = (app, sslKeyFilename, sslCertFilename, port, co
|
|
|
73
120
|
const cert = readFileSyncUtf8(sslCertFilename);
|
|
74
121
|
|
|
75
122
|
// Create server
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
77
123
|
const server = https.createServer({key, cert}, app);
|
|
78
124
|
|
|
79
125
|
// Install shutdown handler
|
|
@@ -100,24 +146,33 @@ export const createHttpsServer = (app, sslKeyFilename, sslCertFilename, port, co
|
|
|
100
146
|
export const startHttpServer = async (config) => {
|
|
101
147
|
debug('startHttpServer', config);
|
|
102
148
|
|
|
103
|
-
const expressVersion = getExpressVersion();
|
|
104
|
-
const packageVersion = getPackageVersion();
|
|
105
|
-
|
|
106
149
|
config = z$configType.parse(config);
|
|
107
150
|
|
|
108
|
-
|
|
151
|
+
showConfig(config);
|
|
109
152
|
|
|
110
153
|
// Create express app
|
|
111
154
|
const app = express();
|
|
112
155
|
|
|
156
|
+
// Debug requests
|
|
157
|
+
if (debug.enabled) {
|
|
158
|
+
app.use((req, res, next) => {
|
|
159
|
+
console.log(`Request: "${req.method}" "${req.url}"`);
|
|
160
|
+
next();
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
113
164
|
// Metrics
|
|
114
165
|
const metrics = initMetrics();
|
|
115
166
|
app.use(handlerMetrics(metrics));
|
|
116
167
|
|
|
168
|
+
// Access log
|
|
169
|
+
if (config.loggerFilename.length > 0) {
|
|
170
|
+
app.use(handlerLogger(config.loggerFilename));
|
|
171
|
+
}
|
|
172
|
+
|
|
117
173
|
// Serving static files
|
|
118
174
|
for (const i of config.routeStatic) {
|
|
119
175
|
app.use(i.route, express.static(i.directoryPath));
|
|
120
|
-
console.log(`Static resources on "${i.route}" from directory ${i.directoryPath}`);
|
|
121
176
|
}
|
|
122
177
|
|
|
123
178
|
// Default middleware
|
|
@@ -127,12 +182,6 @@ export const startHttpServer = async (config) => {
|
|
|
127
182
|
app.use(cookieParser());
|
|
128
183
|
app.use(compression());
|
|
129
184
|
|
|
130
|
-
// Access log
|
|
131
|
-
if (config.loggerFilename.length > 0) {
|
|
132
|
-
console.log(`Access log in "${config.loggerFilename}"`);
|
|
133
|
-
app.use(handlerLogger(config.loggerFilename));
|
|
134
|
-
}
|
|
135
|
-
|
|
136
185
|
/** @type {Pool[]} */
|
|
137
186
|
const connectionPools = [];
|
|
138
187
|
|
|
@@ -143,11 +192,6 @@ export const startHttpServer = async (config) => {
|
|
|
143
192
|
connectionPools.push(pool);
|
|
144
193
|
|
|
145
194
|
app.use([`${i.route}/:name`, i.route], handlerWebPlSql(pool, i));
|
|
146
|
-
|
|
147
|
-
console.log(`Application route "http://localhost:${config.port}${i.route}"`);
|
|
148
|
-
console.log(` Oracle user: ${i.user}`);
|
|
149
|
-
console.log(` Oracle server: ${i.connectString}`);
|
|
150
|
-
console.log(` Oracle document table: ${i.documentTable}`);
|
|
151
195
|
}
|
|
152
196
|
|
|
153
197
|
// Update metrics every second
|
package/src/trace.js
CHANGED
|
@@ -10,7 +10,7 @@ import util from 'node:util';
|
|
|
10
10
|
* Return a string representation of the value.
|
|
11
11
|
*
|
|
12
12
|
* @param {unknown} value - Any value.
|
|
13
|
-
* @param {number | null} depth - Specifies the number of times to recurse while formatting object
|
|
13
|
+
* @param {number | null} depth - Specifies the number of times to recurse while formatting object.
|
|
14
14
|
* @returns {string} - The string representation.
|
|
15
15
|
*/
|
|
16
16
|
export const inspect = (value, depth = null) => util.inspect(value, {showHidden: false, depth, colors: false});
|
package/src/types.js
CHANGED
|
@@ -14,12 +14,10 @@ export const z$errorStyleType = z.enum(['basic', 'debug']);
|
|
|
14
14
|
* @property {string} route - The Static route path.
|
|
15
15
|
* @property {string} directoryPath - The Static directory.
|
|
16
16
|
*/
|
|
17
|
-
export const z$configStaticType = z
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
})
|
|
22
|
-
.strict();
|
|
17
|
+
export const z$configStaticType = z.strictObject({
|
|
18
|
+
route: z.string(),
|
|
19
|
+
directoryPath: z.string(),
|
|
20
|
+
});
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* @typedef {object} configPlSqlHandlerType
|
|
@@ -32,17 +30,15 @@ export const z$configStaticType = z
|
|
|
32
30
|
* @property {Record<string, string>} [cgi] - The additional CGI.
|
|
33
31
|
* @property {errorStyleType} errorStyle - The error style.
|
|
34
32
|
*/
|
|
35
|
-
export const z$configPlSqlHandlerType = z
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})
|
|
45
|
-
.strict();
|
|
33
|
+
export const z$configPlSqlHandlerType = z.strictObject({
|
|
34
|
+
defaultPage: z.string(),
|
|
35
|
+
pathAlias: z.string().optional(),
|
|
36
|
+
pathAliasProcedure: z.string().optional(),
|
|
37
|
+
documentTable: z.string(),
|
|
38
|
+
exclusionList: z.array(z.string()).optional(),
|
|
39
|
+
requestValidationFunction: z.string().optional(),
|
|
40
|
+
errorStyle: z$errorStyleType,
|
|
41
|
+
});
|
|
46
42
|
|
|
47
43
|
/**
|
|
48
44
|
* @typedef {object} configPlSqlConfigType
|
|
@@ -51,19 +47,20 @@ export const z$configPlSqlHandlerType = z
|
|
|
51
47
|
* @property {string} password - The Oracle password.
|
|
52
48
|
* @property {string} connectString - The Oracle connect string.
|
|
53
49
|
*/
|
|
54
|
-
export const z$configPlSqlConfigType = z
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
.strict();
|
|
50
|
+
export const z$configPlSqlConfigType = z.strictObject({
|
|
51
|
+
route: z.string(),
|
|
52
|
+
user: z.string(),
|
|
53
|
+
password: z.string(),
|
|
54
|
+
connectString: z.string(),
|
|
55
|
+
});
|
|
62
56
|
|
|
63
57
|
/**
|
|
64
58
|
* @typedef {configPlSqlHandlerType & configPlSqlConfigType} configPlSqlType
|
|
65
59
|
*/
|
|
66
|
-
export const z$configPlSqlType = z
|
|
60
|
+
export const z$configPlSqlType = z.strictObject({
|
|
61
|
+
...z$configPlSqlHandlerType.shape,
|
|
62
|
+
...z$configPlSqlConfigType.shape,
|
|
63
|
+
});
|
|
67
64
|
|
|
68
65
|
/**
|
|
69
66
|
* @typedef {object} configType
|
|
@@ -73,15 +70,13 @@ export const z$configPlSqlType = z$configPlSqlHandlerType.merge(z$configPlSqlCon
|
|
|
73
70
|
* @property {string} loggerFilename - name of the request logger filename or '' if not required.
|
|
74
71
|
* @property {boolean} monitorConsole - Enable console status monitor.
|
|
75
72
|
*/
|
|
76
|
-
export const z$configType = z
|
|
77
|
-
.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
84
|
-
.strict();
|
|
73
|
+
export const z$configType = z.strictObject({
|
|
74
|
+
port: z.number(),
|
|
75
|
+
routeStatic: z.array(z$configStaticType),
|
|
76
|
+
routePlSql: z.array(z$configPlSqlType),
|
|
77
|
+
loggerFilename: z.string(),
|
|
78
|
+
monitorConsole: z.boolean(),
|
|
79
|
+
});
|
|
85
80
|
|
|
86
81
|
/**
|
|
87
82
|
* Environment variables as string key-value pairs
|
package/types/server.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export function showConfig(config: configType): void;
|
|
1
2
|
export function createHttpServer(app: Express, port: number, connectionPools: Pool[]): Promise<http.Server>;
|
|
2
3
|
export function createHttpsServer(app: Express, sslKeyFilename: string, sslCertFilename: string, port: number, connectionPools: Pool[]): Promise<https.Server>;
|
|
3
4
|
export function startHttpServer(config: configType): Promise<void>;
|
|
@@ -9,3 +10,5 @@ export type NextFunction = import("express").NextFunction;
|
|
|
9
10
|
export type Pool = import("oracledb").Pool;
|
|
10
11
|
export type environmentType = import("./types.js").environmentType;
|
|
11
12
|
export type configType = import("./types.js").configType;
|
|
13
|
+
import http from 'node:http';
|
|
14
|
+
import https from 'node:https';
|
package/types/stream.d.ts
CHANGED
package/types/trace.d.ts
CHANGED
package/types/types.d.ts
CHANGED
|
@@ -4,13 +4,19 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {'basic' | 'debug'} errorStyleType
|
|
6
6
|
*/
|
|
7
|
-
export const z$errorStyleType:
|
|
7
|
+
export const z$errorStyleType: z.ZodEnum<{
|
|
8
|
+
basic: "basic";
|
|
9
|
+
debug: "debug";
|
|
10
|
+
}>;
|
|
8
11
|
/**
|
|
9
12
|
* @typedef {object} configStaticType
|
|
10
13
|
* @property {string} route - The Static route path.
|
|
11
14
|
* @property {string} directoryPath - The Static directory.
|
|
12
15
|
*/
|
|
13
|
-
export const z$configStaticType:
|
|
16
|
+
export const z$configStaticType: z.ZodObject<{
|
|
17
|
+
route: z.ZodString;
|
|
18
|
+
directoryPath: z.ZodString;
|
|
19
|
+
}, z.core.$strict>;
|
|
14
20
|
/**
|
|
15
21
|
* @typedef {object} configPlSqlHandlerType
|
|
16
22
|
* @property {string} defaultPage - The default page.
|
|
@@ -22,7 +28,18 @@ export const z$configStaticType: any;
|
|
|
22
28
|
* @property {Record<string, string>} [cgi] - The additional CGI.
|
|
23
29
|
* @property {errorStyleType} errorStyle - The error style.
|
|
24
30
|
*/
|
|
25
|
-
export const z$configPlSqlHandlerType:
|
|
31
|
+
export const z$configPlSqlHandlerType: z.ZodObject<{
|
|
32
|
+
defaultPage: z.ZodString;
|
|
33
|
+
pathAlias: z.ZodOptional<z.ZodString>;
|
|
34
|
+
pathAliasProcedure: z.ZodOptional<z.ZodString>;
|
|
35
|
+
documentTable: z.ZodString;
|
|
36
|
+
exclusionList: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
+
requestValidationFunction: z.ZodOptional<z.ZodString>;
|
|
38
|
+
errorStyle: z.ZodEnum<{
|
|
39
|
+
basic: "basic";
|
|
40
|
+
debug: "debug";
|
|
41
|
+
}>;
|
|
42
|
+
}, z.core.$strict>;
|
|
26
43
|
/**
|
|
27
44
|
* @typedef {object} configPlSqlConfigType
|
|
28
45
|
* @property {string} route - The PL/SQL route path.
|
|
@@ -30,11 +47,31 @@ export const z$configPlSqlHandlerType: any;
|
|
|
30
47
|
* @property {string} password - The Oracle password.
|
|
31
48
|
* @property {string} connectString - The Oracle connect string.
|
|
32
49
|
*/
|
|
33
|
-
export const z$configPlSqlConfigType:
|
|
50
|
+
export const z$configPlSqlConfigType: z.ZodObject<{
|
|
51
|
+
route: z.ZodString;
|
|
52
|
+
user: z.ZodString;
|
|
53
|
+
password: z.ZodString;
|
|
54
|
+
connectString: z.ZodString;
|
|
55
|
+
}, z.core.$strict>;
|
|
34
56
|
/**
|
|
35
57
|
* @typedef {configPlSqlHandlerType & configPlSqlConfigType} configPlSqlType
|
|
36
58
|
*/
|
|
37
|
-
export const z$configPlSqlType:
|
|
59
|
+
export const z$configPlSqlType: z.ZodObject<{
|
|
60
|
+
route: z.ZodString;
|
|
61
|
+
user: z.ZodString;
|
|
62
|
+
password: z.ZodString;
|
|
63
|
+
connectString: z.ZodString;
|
|
64
|
+
defaultPage: z.ZodString;
|
|
65
|
+
pathAlias: z.ZodOptional<z.ZodString>;
|
|
66
|
+
pathAliasProcedure: z.ZodOptional<z.ZodString>;
|
|
67
|
+
documentTable: z.ZodString;
|
|
68
|
+
exclusionList: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
requestValidationFunction: z.ZodOptional<z.ZodString>;
|
|
70
|
+
errorStyle: z.ZodEnum<{
|
|
71
|
+
basic: "basic";
|
|
72
|
+
debug: "debug";
|
|
73
|
+
}>;
|
|
74
|
+
}, z.core.$strict>;
|
|
38
75
|
/**
|
|
39
76
|
* @typedef {object} configType
|
|
40
77
|
* @property {number} port - The server port number.
|
|
@@ -43,7 +80,31 @@ export const z$configPlSqlType: any;
|
|
|
43
80
|
* @property {string} loggerFilename - name of the request logger filename or '' if not required.
|
|
44
81
|
* @property {boolean} monitorConsole - Enable console status monitor.
|
|
45
82
|
*/
|
|
46
|
-
export const z$configType:
|
|
83
|
+
export const z$configType: z.ZodObject<{
|
|
84
|
+
port: z.ZodNumber;
|
|
85
|
+
routeStatic: z.ZodArray<z.ZodObject<{
|
|
86
|
+
route: z.ZodString;
|
|
87
|
+
directoryPath: z.ZodString;
|
|
88
|
+
}, z.core.$strict>>;
|
|
89
|
+
routePlSql: z.ZodArray<z.ZodObject<{
|
|
90
|
+
route: z.ZodString;
|
|
91
|
+
user: z.ZodString;
|
|
92
|
+
password: z.ZodString;
|
|
93
|
+
connectString: z.ZodString;
|
|
94
|
+
defaultPage: z.ZodString;
|
|
95
|
+
pathAlias: z.ZodOptional<z.ZodString>;
|
|
96
|
+
pathAliasProcedure: z.ZodOptional<z.ZodString>;
|
|
97
|
+
documentTable: z.ZodString;
|
|
98
|
+
exclusionList: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
99
|
+
requestValidationFunction: z.ZodOptional<z.ZodString>;
|
|
100
|
+
errorStyle: z.ZodEnum<{
|
|
101
|
+
basic: "basic";
|
|
102
|
+
debug: "debug";
|
|
103
|
+
}>;
|
|
104
|
+
}, z.core.$strict>>;
|
|
105
|
+
loggerFilename: z.ZodString;
|
|
106
|
+
monitorConsole: z.ZodBoolean;
|
|
107
|
+
}, z.core.$strict>;
|
|
47
108
|
export type BindParameter = import("oracledb").BindParameter;
|
|
48
109
|
export type errorStyleType = "basic" | "debug";
|
|
49
110
|
export type configStaticType = {
|
|
@@ -249,3 +310,4 @@ export type metricsType = {
|
|
|
249
310
|
*/
|
|
250
311
|
requestsInLastInterval: number;
|
|
251
312
|
};
|
|
313
|
+
import z from 'zod';
|