The Express Middleware for Oracle PL/SQL
npm install web_plsql [![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]


Please feel free to try and suggest any improvements. Your thoughts and ideas are most welcome.
npm i)npm i --omit=dev web_plsql)examples/sql directory, start SQLPLus, connect to the database as SYS specifying the SYSDBA roleInstall and install the sample schema @examples/sql/install.sql.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.http://localhost/sample.web_plsql includes a built-in Admin Console for real-time monitoring and management of your gateway.
startServer API. You can configure it via the admin property in the main configuration object.``typescript`
/**
* @typedef {object} configAdminType
* @property {boolean} [enabled=true] - Whether the admin console is enabled.
* @property {string} [route='/admin'] - The route path for the admin console.
*/
Access the console at http://localhost: (e.g., http://localhost:8080/admin).
There are 2 options on how to use the web_plsql express middleware:
- Use the predefined startServer api in src/server.js like in the examples/config-native.js examplehandlerWebPlSql
- Hand craft a new Express server using the middleware in src/handlerPlSql.js
The startServer api uses the following configuration object:
`typescript
/**
* @typedef {'basic' | 'debug'} errorStyleType
*/
/**
* @typedef {object} configStaticType
* @property {string} route - The Static route path.
* @property {string} directoryPath - The Static directory.
*/
/**
* @typedef {(connection: Connection, procedure: string) => void | Promise
* @typedef {'commit' | 'rollback' | transactionCallbackType | undefined | null} transactionModeType
*/
/**
* @typedef {object} configPlSqlHandlerType
* @property {string} defaultPage - The default page.
* @property {string} [pathAlias] - The path alias.
* @property {string} [pathAliasProcedure] - The path alias.
* @property {string} documentTable - The document table.
* @property {string[]} [exclusionList] - The exclusion list.
* @property {string} [requestValidationFunction] - The request validation function.
* @property {Record
* @property {transactionModeType} [transactionMode='commit'] - Specifies an optional transaction mode.
* "commit" this automatically commits any open transaction after each request. This is the defaults because this is what mod_plsql and ohs are doing.
* "rollback" this automatically rolles back any open transaction after each request.
* "transactionCallbackType" this allows to defined a custom handler as a JavaScript function.
* @property {errorStyleType} errorStyle - The error style.
*/
/**
* @typedef {object} configPlSqlConfigType
* @property {string} route - The PL/SQL route path.
* @property {string} user - The Oracle username.
* @property {string} password - The Oracle password.
* @property {string} connectString - The Oracle connect string.
*/
/**
* @typedef {configPlSqlHandlerType & configPlSqlConfigType} configPlSqlType
*/
/**
* @typedef {object} configType
* @property {number} port - The server port number.
* @property {configAdminType} [admin] - The admin console configuration.
* @property {configStaticType[]} routeStatic - The static routes.
* @property {configPlSqlType[]} routePlSql - The PL/SQL routes.
* @property {number} [uploadFileSizeLimit] - Maximum size of each uploaded file in bytes or no limit if omitted.
* @property {string} loggerFilename - name of the request logger filename or '' if not required.
*/
`
middlewareWIP
The following mod_plsql DAD configuration translates to the configuration options as follows:
DAD
``
SetHandler pls_handler
Order deny,allow
Allow from all
PlsqlDatabaseUsername sample
PlsqlDatabasePassword sample
PlsqlDatabaseConnectString localhost:1521/ORCL
PlsqlDefaultPage sample_pkg.pageIndex
PlsqlDocumentTablename doctable
PlsqlPathAlias myalias
PlsqlPathAliasProcedure sample_pkg.page_path_alias
PlsqlExclusionList sample_pkg.page_exclusion_list
PlsqlRequestValidationFunction sample_pkg.request_validation_function
PlsqlErrorStyle DebugStyle
PlsqlNlsLanguage AMERICAN_AMERICA.UTF8
mod_plsql
`typescript`
{
port: 80,
routeStatic: [
{
route: '/static',
directoryPath: 'examples/static',
},
],
routePlSql: [
{
route: '/sample',
user: 'sample', // PlsqlDatabaseUserName
password: 'sample', // PlsqlDatabasePassword
connectString: 'localhost:1521/ORCL', // PlsqlDatabaseConnectString
defaultPage: 'sample_pkg.page_index', // PlsqlDefaultPage
documentTable: 'doctable', // PlsqlDocumentTablename
exclusionList: ['sample_pkg.page_exclusion_list'], // PlsqlExclusionList
requestValidationFunction: 'sample_pkg.request_validation_function', // PlsqlRequestValidationFunction
pathAlias: 'myalias', // PlsqlPathAlias
pathAliasProcedure: 'sample_pkg.page_path_alias', // PlsqlPathAliasProcedure
transactionMode: 'commit',
errorStyle: 'debug', // PlsqlErrorStyle
},
],
uploadFileSizeLimit: 50 1024 1024, // 50MB
loggerFilename: 'access.log', // PlsqlLogEnable and PlsqlLogDirectory
}
....
[npm-image]: https://img.shields.io/npm/v/web_plsql.svg
[npm-url]: https://npmjs.org/package/web_plsql
[downloads-image]: https://img.shields.io/npm/dm/web_plsql.svg
[downloads-url]: https://npmjs.org/package/web_plsql