web_plsql 0.14.2 → 0.15.1

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
  */
@@ -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.14.2",
3
+ "version": "0.15.1",
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);
@@ -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
  /**
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // server
2
+ export {getVersion} from './server/version.js';
2
3
  export {createServer, startServer, loadConfig, startServerConfig} from './server/server.js';
3
4
  export * from './util/shutdown.js';
4
5
 
@@ -1,3 +1,5 @@
1
+ import {getVersion} from './version.js';
2
+
1
3
  /**
2
4
  * @typedef {import('../types.js').configType} configType
3
5
  */
@@ -11,11 +13,12 @@ export const showConfig = (config) => {
11
13
  const LINE = '-'.repeat(80);
12
14
 
13
15
  console.log(LINE);
14
- console.log('NODE PL/SQL SERVER');
16
+ console.log(`NODE PL/SQL SERVER version ${getVersion()}`);
15
17
  console.log(LINE);
16
18
 
17
19
  console.log(`Server port: ${config.port}`);
18
20
  console.log(`Access log: ${config.loggerFilename.length > 0 ? config.loggerFilename : ''}`);
21
+ console.log(`Upload file size limit: ${typeof config.uploadFileSizeLimit === 'number' ? `${config.uploadFileSizeLimit} bytes` : 'any'}`);
19
22
 
20
23
  if (config.routeStatic.length > 0) {
21
24
  console.log(LINE);
@@ -1,6 +1,5 @@
1
1
  import debugModule from 'debug';
2
2
  const debug = debugModule('webplsql:server');
3
-
4
3
  import http from 'node:http';
5
4
  import https from 'node:https';
6
5
  import express from 'express';
@@ -85,9 +84,9 @@ export const startServer = async (config, ssl) => {
85
84
  }
86
85
 
87
86
  // Default middleware
88
- app.use(handlerUpload());
89
- app.use(express.json());
90
- app.use(express.urlencoded({extended: true}));
87
+ app.use(handlerUpload(internalConfig.uploadFileSizeLimit));
88
+ app.use(express.json({limit: '50mb'}));
89
+ app.use(express.urlencoded({limit: '50mb', extended: true}));
91
90
  app.use(cookieParser());
92
91
  app.use(compression());
93
92
 
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Returns the current library version
3
+ * @returns {string} - Version.
4
+ */
5
+ export const getVersion = () => '0.15.1';
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='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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { getVersion } from "./server/version.js";
1
2
  export * from "./util/shutdown.js";
2
3
  export * from "./util/oracle.js";
3
4
  export * from "./util/file.js";
@@ -0,0 +1 @@
1
+ export function getVersion(): string;
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='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;
@@ -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
  */