web_plsql 0.14.1 → 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 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
  */
@@ -58,13 +58,7 @@ The `startServer` api uses the following configuration object:
58
58
  */
59
59
 
60
60
  /**
61
- * @callback transactionCallbackType
62
- * @param {Request} req - Incoming request object.
63
- * @param {import('oracledb').Connection} connection - Active database connection pool.
64
- * @returns {void | Promise<void>}
65
- */
66
-
67
- /**
61
+ * @typedef {(connection: Connection, procedure: string) => void | Promise<void>} transactionCallbackType
68
62
  * @typedef {'commit' | 'rollback' | transactionCallbackType | undefined | null} transactionModeType
69
63
  */
70
64
 
@@ -101,6 +95,7 @@ The `startServer` api uses the following configuration object:
101
95
  * @property {number} port - The server port number.
102
96
  * @property {configStaticType[]} routeStatic - The static routes.
103
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.
104
99
  * @property {string} loggerFilename - name of the request logger filename or '' if not required.
105
100
  */
106
101
  ```
@@ -134,7 +129,7 @@ The following mod_plsql DAD configuration translates to the configuration option
134
129
  ```
135
130
 
136
131
  **mod_plsql**
137
- ```
132
+ ```typescript
138
133
  {
139
134
  port: 80,
140
135
  routeStatic: [
@@ -155,9 +150,11 @@ The following mod_plsql DAD configuration translates to the configuration option
155
150
  requestValidationFunction: 'sample_pkg.request_validation_function', // PlsqlRequestValidationFunction
156
151
  pathAlias: 'myalias', // PlsqlPathAlias
157
152
  pathAliasProcedure: 'sample_pkg.page_path_alias', // PlsqlPathAliasProcedure
153
+ transactionMode: 'commit',
158
154
  errorStyle: 'debug', // PlsqlErrorStyle
159
155
  },
160
156
  ],
157
+ uploadFileSizeLimit: 50 * 1024 * 1024, // 50MB
161
158
  loggerFilename: 'access.log', // PlsqlLogEnable and PlsqlLogDirectory
162
159
  }
163
160
  ```
@@ -55,14 +55,12 @@ void startServer({
55
55
  requestValidationFunction: 'sample_pkg.request_validation_function', // PlsqlRequestValidationFunction
56
56
  pathAlias: 'myalias', // PlsqlPathAlias
57
57
  pathAliasProcedure: 'sample_pkg.page_path_alias', // PlsqlPathAliasProcedure
58
- transactionMode: 'commit',
59
- /*
60
- transactionMode: async (req, connection) => {
58
+ //transactionMode: 'commit',
59
+ transactionMode: async (connection, procedure) => {
61
60
  if (await hasOpenTransaction(connection)) {
62
- console.log(`We detected an open transaction in "${req.originalUrl}"`);
61
+ console.log(`We detected an open transaction in "${procedure}"`);
63
62
  }
64
63
  },
65
- */
66
64
  errorStyle: 'debug', // PlsqlErrorStyle
67
65
  },
68
66
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web_plsql",
3
- "version": "0.14.1",
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.12"
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.9.2",
81
+ "@types/node": "24.10.1",
82
82
  "@types/oracledb": "6.10.0",
83
83
  "@types/supertest": "6.0.3",
84
- "eslint": "9.39.0",
85
- "eslint-plugin-jsdoc": "61.1.11",
86
- "prettier": "3.6.2",
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.46.2"
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: 50 * 1024 * 1024, // 50MB limit
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('executeRequest: ENTER');
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('executeRequest: cgiObj=', cgiObj);
41
+ debug('processRequest: cgiObj=', cgiObj);
42
42
 
43
43
  // Does the request contain any files
44
44
  const filesToUpload = getFiles(req);
45
- debug('executeRequest: filesToUpload=', filesToUpload);
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('executeRequest: argObj=', argObj);
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);
@@ -68,7 +68,7 @@ export const processRequest = async (req, res, options, connectionPool) => {
68
68
  await connection.rollback();
69
69
  } else if (typeof options.transactionMode === 'function') {
70
70
  debug('transactionMode: callback');
71
- const result = options.transactionMode(req, connection);
71
+ const result = options.transactionMode(connection, req.params.name);
72
72
  debug('transactionMode: callback restult', result);
73
73
  if (result && typeof result.then === 'function') {
74
74
  await result;
@@ -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('executeRequest: EXIT');
84
+ debug('processRequest: EXIT');
85
85
  };
86
86
 
87
87
  /**
@@ -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);
@@ -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
@@ -23,7 +23,7 @@ export const z$configStaticType = z.strictObject({
23
23
  });
24
24
 
25
25
  /**
26
- * @typedef {(req: Request, connection: Connection) => void | Promise<void>} transactionCallbackType
26
+ * @typedef {(connection: Connection, procedure: string) => void | Promise<void>} transactionCallbackType
27
27
  * @typedef {'commit' | 'rollback' | transactionCallbackType | undefined | null} transactionModeType
28
28
  */
29
29
 
@@ -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='commit'] - Specifies an optional transaction mode.
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,5 +1,3 @@
1
- /* eslint-disable jsdoc/no-undefined-types */
2
-
3
1
  /**
4
2
  * Is the given value a string or an array of strings
5
3
  * @param {unknown} value - The value to check.
@@ -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
@@ -21,7 +21,7 @@ export const z$configStaticType: z.ZodObject<{
21
21
  directoryPath: z.ZodString;
22
22
  }, z.core.$strict>;
23
23
  /**
24
- * @typedef {(req: Request, connection: Connection) => void | Promise<void>} transactionCallbackType
24
+ * @typedef {(connection: Connection, procedure: string) => void | Promise<void>} transactionCallbackType
25
25
  * @typedef {'commit' | 'rollback' | transactionCallbackType | undefined | null} transactionModeType
26
26
  */
27
27
  /**
@@ -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='commit'] - Specifies an optional transaction mode.
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;
@@ -132,7 +134,7 @@ export type configStaticType = {
132
134
  */
133
135
  directoryPath: string;
134
136
  };
135
- export type transactionCallbackType = (req: Request, connection: Connection) => void | Promise<void>;
137
+ export type transactionCallbackType = (connection: Connection, procedure: string) => void | Promise<void>;
136
138
  export type transactionModeType = "commit" | "rollback" | transactionCallbackType | undefined | null;
137
139
  export type configPlSqlHandlerType = {
138
140
  /**
@@ -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
  */