web_plsql 0.14.2 → 0.15.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 +5 -2
- package/package.json +7 -8
- package/src/handler/handlerUpload.js +4 -12
- package/src/handler/plsql/request.js +5 -5
- package/src/server/config.js +1 -0
- package/src/server/server.js +3 -3
- package/src/types.js +3 -1
- package/src/util/type.js +0 -2
- package/types/handler/handlerUpload.d.ts +1 -1
- package/types/types.d.ts +7 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ There are 2 options on how to use the web_plsql express middleware:
|
|
|
46
46
|
|
|
47
47
|
The `startServer` api uses the following configuration object:
|
|
48
48
|
|
|
49
|
-
```
|
|
49
|
+
```typescript
|
|
50
50
|
/**
|
|
51
51
|
* @typedef {'basic' | 'debug'} errorStyleType
|
|
52
52
|
*/
|
|
@@ -95,6 +95,7 @@ The `startServer` api uses the following configuration object:
|
|
|
95
95
|
* @property {number} port - The server port number.
|
|
96
96
|
* @property {configStaticType[]} routeStatic - The static routes.
|
|
97
97
|
* @property {configPlSqlType[]} routePlSql - The PL/SQL routes.
|
|
98
|
+
* @property {number} [uploadFileSizeLimit] - Maximum size of each uploaded file in bytes or no limit if omitted.
|
|
98
99
|
* @property {string} loggerFilename - name of the request logger filename or '' if not required.
|
|
99
100
|
*/
|
|
100
101
|
```
|
|
@@ -128,7 +129,7 @@ The following mod_plsql DAD configuration translates to the configuration option
|
|
|
128
129
|
```
|
|
129
130
|
|
|
130
131
|
**mod_plsql**
|
|
131
|
-
```
|
|
132
|
+
```typescript
|
|
132
133
|
{
|
|
133
134
|
port: 80,
|
|
134
135
|
routeStatic: [
|
|
@@ -149,9 +150,11 @@ The following mod_plsql DAD configuration translates to the configuration option
|
|
|
149
150
|
requestValidationFunction: 'sample_pkg.request_validation_function', // PlsqlRequestValidationFunction
|
|
150
151
|
pathAlias: 'myalias', // PlsqlPathAlias
|
|
151
152
|
pathAliasProcedure: 'sample_pkg.page_path_alias', // PlsqlPathAliasProcedure
|
|
153
|
+
transactionMode: 'commit',
|
|
152
154
|
errorStyle: 'debug', // PlsqlErrorStyle
|
|
153
155
|
},
|
|
154
156
|
],
|
|
157
|
+
uploadFileSizeLimit: 50 * 1024 * 1024, // 50MB
|
|
155
158
|
loggerFilename: 'access.log', // PlsqlLogEnable and PlsqlLogDirectory
|
|
156
159
|
}
|
|
157
160
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web_plsql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"author": "Dieter Oberkofler <dieter.oberkofler@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "The Express Middleware for Oracle PL/SQL",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"morgan": "1.10.1",
|
|
68
68
|
"multer": "2.0.2",
|
|
69
69
|
"rotating-file-stream": "3.2.7",
|
|
70
|
-
"zod": "4.1.
|
|
70
|
+
"zod": "4.1.13"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/basic-auth": "1.1.8",
|
|
@@ -78,16 +78,15 @@
|
|
|
78
78
|
"@types/fs-extra": "11.0.4",
|
|
79
79
|
"@types/morgan": "1.9.10",
|
|
80
80
|
"@types/multer": "2.0.0",
|
|
81
|
-
"@types/node": "24.
|
|
81
|
+
"@types/node": "24.10.1",
|
|
82
82
|
"@types/oracledb": "6.10.0",
|
|
83
83
|
"@types/supertest": "6.0.3",
|
|
84
|
-
"eslint": "9.39.
|
|
85
|
-
"eslint-plugin-jsdoc": "61.1
|
|
86
|
-
"prettier": "3.
|
|
87
|
-
"rimraf": "6.1.0",
|
|
84
|
+
"eslint": "9.39.1",
|
|
85
|
+
"eslint-plugin-jsdoc": "61.4.1",
|
|
86
|
+
"prettier": "3.7.1",
|
|
88
87
|
"shx": "0.4.0",
|
|
89
88
|
"supertest": "7.1.4",
|
|
90
89
|
"typescript": "5.9.3",
|
|
91
|
-
"typescript-eslint": "8.
|
|
90
|
+
"typescript-eslint": "8.48.0"
|
|
92
91
|
}
|
|
93
92
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//import path from 'node:path';
|
|
2
1
|
import multer from 'multer';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -12,21 +11,14 @@ import multer from 'multer';
|
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Create the upload middleware.
|
|
14
|
+
* @param {number} [uploadFileSizeLimit] - Maximum size of each uploaded file in bytes or no limit if omitted.
|
|
15
15
|
* @returns {RequestHandler} - Request handler.
|
|
16
16
|
*/
|
|
17
|
-
export const handlerUpload = () => {
|
|
17
|
+
export const handlerUpload = (uploadFileSizeLimit = Infinity) => {
|
|
18
18
|
const upload = multer({
|
|
19
|
-
storage: multer.diskStorage({
|
|
20
|
-
/*
|
|
21
|
-
destination: '/tmp/webplsql',
|
|
22
|
-
filename: (req, file, cb) => {
|
|
23
|
-
const uniqueSuffix = `${Date.now()}-${Math.round(Math.random() * 1e9)}`;
|
|
24
|
-
cb(null, `${file.fieldname}-${uniqueSuffix}${path.extname(file.originalname)}`);
|
|
25
|
-
},
|
|
26
|
-
*/
|
|
27
|
-
}),
|
|
19
|
+
storage: multer.diskStorage({}),
|
|
28
20
|
limits: {
|
|
29
|
-
fileSize:
|
|
21
|
+
fileSize: uploadFileSizeLimit,
|
|
30
22
|
},
|
|
31
23
|
});
|
|
32
24
|
|
|
@@ -31,18 +31,18 @@ import {isStringOrArrayOfString} from '../../util/type.js';
|
|
|
31
31
|
* @returns {Promise<void>} - Promise resolving to th page
|
|
32
32
|
*/
|
|
33
33
|
export const processRequest = async (req, res, options, connectionPool) => {
|
|
34
|
-
debug('
|
|
34
|
+
debug('processRequest: ENTER');
|
|
35
35
|
|
|
36
36
|
// open database connection
|
|
37
37
|
const connection = await connectionPool.getConnection();
|
|
38
38
|
|
|
39
39
|
// Get the CGI
|
|
40
40
|
const cgiObj = getCGI(req, options.documentTable ?? '', options.cgi ?? {});
|
|
41
|
-
debug('
|
|
41
|
+
debug('processRequest: cgiObj=', cgiObj);
|
|
42
42
|
|
|
43
43
|
// Does the request contain any files
|
|
44
44
|
const filesToUpload = getFiles(req);
|
|
45
|
-
debug('
|
|
45
|
+
debug('processRequest: filesToUpload=', filesToUpload);
|
|
46
46
|
|
|
47
47
|
// Add the query properties
|
|
48
48
|
/** @type {argObjType} */
|
|
@@ -57,7 +57,7 @@ export const processRequest = async (req, res, options, connectionPool) => {
|
|
|
57
57
|
|
|
58
58
|
// Does the request contain a body
|
|
59
59
|
Object.assign(argObj, normalizeBody(req));
|
|
60
|
-
debug('
|
|
60
|
+
debug('processRequest: argObj=', argObj);
|
|
61
61
|
|
|
62
62
|
// invoke the Oracle procedure and get the page contenst
|
|
63
63
|
await invokeProcedure(req, res, argObj, cgiObj, filesToUpload, options, connection);
|
|
@@ -81,7 +81,7 @@ export const processRequest = async (req, res, options, connectionPool) => {
|
|
|
81
81
|
// close database connection
|
|
82
82
|
await connection.release();
|
|
83
83
|
|
|
84
|
-
debug('
|
|
84
|
+
debug('processRequest: EXIT');
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
/**
|
package/src/server/config.js
CHANGED
|
@@ -16,6 +16,7 @@ export const showConfig = (config) => {
|
|
|
16
16
|
|
|
17
17
|
console.log(`Server port: ${config.port}`);
|
|
18
18
|
console.log(`Access log: ${config.loggerFilename.length > 0 ? config.loggerFilename : ''}`);
|
|
19
|
+
console.log(`Upload file size limit: ${typeof config.uploadFileSizeLimit === 'number' ? `${config.uploadFileSizeLimit} bytes` : 'any'}`);
|
|
19
20
|
|
|
20
21
|
if (config.routeStatic.length > 0) {
|
|
21
22
|
console.log(LINE);
|
package/src/server/server.js
CHANGED
|
@@ -85,9 +85,9 @@ export const startServer = async (config, ssl) => {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// Default middleware
|
|
88
|
-
app.use(handlerUpload());
|
|
89
|
-
app.use(express.json());
|
|
90
|
-
app.use(express.urlencoded({extended: true}));
|
|
88
|
+
app.use(handlerUpload(internalConfig.uploadFileSizeLimit));
|
|
89
|
+
app.use(express.json({limit: '50mb'}));
|
|
90
|
+
app.use(express.urlencoded({limit: '50mb', extended: true}));
|
|
91
91
|
app.use(cookieParser());
|
|
92
92
|
app.use(compression());
|
|
93
93
|
|
package/src/types.js
CHANGED
|
@@ -36,7 +36,7 @@ export const z$configStaticType = z.strictObject({
|
|
|
36
36
|
* @property {string[]} [exclusionList] - The exclusion list.
|
|
37
37
|
* @property {string} [requestValidationFunction] - The request validation function.
|
|
38
38
|
* @property {Record<string, string>} [cgi] - The additional CGI.
|
|
39
|
-
* @property {transactionModeType} [transactionMode
|
|
39
|
+
* @property {transactionModeType} [transactionMode] - Specifies an optional transaction mode.
|
|
40
40
|
* "commit" this automatically commits any open transaction after each request. This is the defaults because this is what mod_plsql and ohs are doing.
|
|
41
41
|
* "rollback" this automatically rolles back any open transaction after each request.
|
|
42
42
|
* "transactionCallbackType" this allows to defined a custom handler as a JavaScript function.
|
|
@@ -80,12 +80,14 @@ export const z$configPlSqlType = z.strictObject({
|
|
|
80
80
|
* @property {number} port - The server port number.
|
|
81
81
|
* @property {configStaticType[]} routeStatic - The static routes.
|
|
82
82
|
* @property {configPlSqlType[]} routePlSql - The PL/SQL routes.
|
|
83
|
+
* @property {number} [uploadFileSizeLimit] - Maximum size of each uploaded file in bytes or no limit if omitted.
|
|
83
84
|
* @property {string} loggerFilename - name of the request logger filename or '' if not required.
|
|
84
85
|
*/
|
|
85
86
|
export const z$configType = z.strictObject({
|
|
86
87
|
port: z.number(),
|
|
87
88
|
routeStatic: z.array(z$configStaticType),
|
|
88
89
|
routePlSql: z.array(z$configPlSqlType),
|
|
90
|
+
uploadFileSizeLimit: z.number().optional(),
|
|
89
91
|
loggerFilename: z.string(),
|
|
90
92
|
});
|
|
91
93
|
|
package/src/util/type.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function handlerUpload(): RequestHandler;
|
|
1
|
+
export function handlerUpload(uploadFileSizeLimit?: number): RequestHandler;
|
|
2
2
|
export type RequestHandler = import("express").RequestHandler;
|
|
3
3
|
export type Response = import("express").Response;
|
|
4
4
|
export type NextFunction = import("express").NextFunction;
|
package/types/types.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export const z$configStaticType: z.ZodObject<{
|
|
|
33
33
|
* @property {string[]} [exclusionList] - The exclusion list.
|
|
34
34
|
* @property {string} [requestValidationFunction] - The request validation function.
|
|
35
35
|
* @property {Record<string, string>} [cgi] - The additional CGI.
|
|
36
|
-
* @property {transactionModeType} [transactionMode
|
|
36
|
+
* @property {transactionModeType} [transactionMode] - Specifies an optional transaction mode.
|
|
37
37
|
* "commit" this automatically commits any open transaction after each request. This is the defaults because this is what mod_plsql and ohs are doing.
|
|
38
38
|
* "rollback" this automatically rolles back any open transaction after each request.
|
|
39
39
|
* "transactionCallbackType" this allows to defined a custom handler as a JavaScript function.
|
|
@@ -90,6 +90,7 @@ export const z$configPlSqlType: z.ZodObject<{
|
|
|
90
90
|
* @property {number} port - The server port number.
|
|
91
91
|
* @property {configStaticType[]} routeStatic - The static routes.
|
|
92
92
|
* @property {configPlSqlType[]} routePlSql - The PL/SQL routes.
|
|
93
|
+
* @property {number} [uploadFileSizeLimit] - Maximum size of each uploaded file in bytes or no limit if omitted.
|
|
93
94
|
* @property {string} loggerFilename - name of the request logger filename or '' if not required.
|
|
94
95
|
*/
|
|
95
96
|
export const z$configType: z.ZodObject<{
|
|
@@ -115,6 +116,7 @@ export const z$configType: z.ZodObject<{
|
|
|
115
116
|
debug: "debug";
|
|
116
117
|
}>;
|
|
117
118
|
}, z.core.$strict>>;
|
|
119
|
+
uploadFileSizeLimit: z.ZodOptional<z.ZodNumber>;
|
|
118
120
|
loggerFilename: z.ZodString;
|
|
119
121
|
}, z.core.$strict>;
|
|
120
122
|
export type BindParameter = import("oracledb").BindParameter;
|
|
@@ -207,6 +209,10 @@ export type configType = {
|
|
|
207
209
|
* - The PL/SQL routes.
|
|
208
210
|
*/
|
|
209
211
|
routePlSql: configPlSqlType[];
|
|
212
|
+
/**
|
|
213
|
+
* - Maximum size of each uploaded file in bytes or no limit if omitted.
|
|
214
|
+
*/
|
|
215
|
+
uploadFileSizeLimit?: number;
|
|
210
216
|
/**
|
|
211
217
|
* - name of the request logger filename or '' if not required.
|
|
212
218
|
*/
|