web_plsql 0.4.0 → 0.5.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/CHANGELOG.md +32 -3
- package/README.md +10 -10
- package/examples/sample.js +18 -1
- package/jest.config.js +207 -0
- package/package.json +29 -57
- package/src/cgi.ts +1 -1
- package/src/errorPage.ts +17 -12
- package/src/fileUpload.ts +2 -2
- package/src/index.ts +2 -2
- package/src/procedure.ts +4 -4
- package/src/procedureError.ts +2 -2
- package/src/request.ts +6 -6
- package/test/{cgi.ts → __tests__/cgi.ts} +5 -5
- package/test/{config.ts → __tests__/config.ts} +5 -5
- package/test/__tests__/errorPage.ts +101 -0
- package/test/{oracledb_mock.ts → __tests__/oracledb_mock.ts} +10 -10
- package/test/{server.ts → __tests__/server.ts} +10 -10
- package/test/{stream.ts → __tests__/stream.ts} +3 -3
- package/test/errorPage.ts +0 -101
- package/tsconfig.test.json +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -5,13 +5,44 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [?.?.?] -
|
|
8
|
+
## [?.?.?] - ????-??-??
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
### Changed
|
|
12
12
|
### Fixed
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
## [0.5.1] - 2022-09-11
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Updated all dependencies.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## [0.5.0] - 2022-05-09
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Replaced mocha with jest.
|
|
25
|
+
- Added support for node 18.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- Updated all dependencies.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## [0.4.2] - 2022-01-17
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- node.js support starting with v16.
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
- Updated all dependencies.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## [0.4.1] - 2021-08-30
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
- Updated all dependencies.
|
|
44
|
+
|
|
45
|
+
|
|
15
46
|
## [0.4.0] - 2021-04-09
|
|
16
47
|
|
|
17
48
|
### Added
|
|
@@ -39,8 +70,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
39
70
|
|
|
40
71
|
## [0.2.0] - 2019-06-02
|
|
41
72
|
|
|
42
|
-
### Added
|
|
43
|
-
|
|
44
73
|
## [0.2.0] - 2019-06-02
|
|
45
74
|
|
|
46
75
|
### Fixed
|
package/README.md
CHANGED
|
@@ -119,11 +119,6 @@ app.listen(PORT);
|
|
|
119
119
|
|
|
120
120
|
# Missing features
|
|
121
121
|
|
|
122
|
-
## Features in mod_plsql that are not (yet) available in web_plsql:
|
|
123
|
-
- Support for APEX 5.
|
|
124
|
-
- Default exclusion list.
|
|
125
|
-
- Basic and custom authentication methods, based on the OWA_SEC package and custom packages.
|
|
126
|
-
|
|
127
122
|
## Supported mod_plsql configuration options:
|
|
128
123
|
- PlsqlDatabaseConnectString -> specified when creating the oracledb connection pool
|
|
129
124
|
- PlsqlDatabaseUserName -> specified when creating the oracledb connection pool
|
|
@@ -136,16 +131,21 @@ app.listen(PORT);
|
|
|
136
131
|
- PlsqlPathAlias -> use the "pathAlias.alias" configuration option
|
|
137
132
|
- PlsqlPathAliasProcedure -> use the "pathAlias.procedure" configuration option
|
|
138
133
|
|
|
139
|
-
##
|
|
134
|
+
## Features in mod_plsql that are planned t be available in web_plsql:
|
|
135
|
+
- PlsqlDocumentPath
|
|
136
|
+
- PlsqlDocumentProcedure
|
|
137
|
+
- PlsqlExclusionList
|
|
138
|
+
- PlsqlRequestValidationFunction
|
|
139
|
+
- Support for APEX 5.
|
|
140
|
+
- Default exclusion list.
|
|
141
|
+
- Basic and custom authentication methods, based on the OWA_SEC package and custom packages.
|
|
142
|
+
|
|
143
|
+
## Configuration options that will not be supported:
|
|
140
144
|
- PlsqlIdleSessionCleanupInterval
|
|
141
145
|
- PlsqlAfterProcedure
|
|
142
146
|
- PlsqlAlwaysDescribeProcedure
|
|
143
147
|
- PlsqlBeforeProcedure
|
|
144
148
|
- PlsqlCGIEnvironmentList
|
|
145
|
-
- PlsqlDocumentPath
|
|
146
|
-
- PlsqlDocumentProcedure
|
|
147
|
-
- PlsqlExclusionList
|
|
148
|
-
- PlsqlRequestValidationFunction
|
|
149
149
|
- PlsqlSessionCookieName
|
|
150
150
|
- PlsqlSessionStateManagement
|
|
151
151
|
- PlsqlTransferMode
|
package/examples/sample.js
CHANGED
|
@@ -79,6 +79,23 @@ app.use(PATH + '/:name?', webplsql(connectionPool, OPTIONS));
|
|
|
79
79
|
// serving static files
|
|
80
80
|
app.use('/static', express.static(path.join(process.cwd(), 'examples/static')));
|
|
81
81
|
|
|
82
|
+
// shutdown
|
|
83
|
+
process.on('SIGTERM', shutDown);
|
|
84
|
+
process.on('SIGINT', shutDown);
|
|
85
|
+
|
|
82
86
|
// listen on port
|
|
83
87
|
console.log(`Sample app is listening on http://localhost:${PORT}${PATH}`);
|
|
84
|
-
app.listen(PORT);
|
|
88
|
+
const server = app.listen(PORT);
|
|
89
|
+
|
|
90
|
+
function shutDown() {
|
|
91
|
+
console.log('Received kill signal, shutting down gracefully');
|
|
92
|
+
server.close(() => {
|
|
93
|
+
console.log('Closed out remaining connections');
|
|
94
|
+
process.exit(0);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
console.error('Could not close connections in time, forcefully shutting down');
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}, 10000);
|
|
101
|
+
}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* For a detailed explanation regarding each configuration property, visit:
|
|
3
|
+
* https://jestjs.io/docs/configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
// All imported modules in your tests should be mocked automatically
|
|
8
|
+
// automock: false,
|
|
9
|
+
|
|
10
|
+
// Stop running tests after `n` failures
|
|
11
|
+
// bail: 0,
|
|
12
|
+
|
|
13
|
+
// The directory where Jest should store its cached dependency information
|
|
14
|
+
// cacheDirectory: "/private/var/folders/2y/kvrr5nws6xz4nx9vnwjxj17w0000gn/T/jest_dx",
|
|
15
|
+
|
|
16
|
+
// Automatically clear mock calls, instances, contexts and results before every test
|
|
17
|
+
// clearMocks: false,
|
|
18
|
+
|
|
19
|
+
// Indicates whether the coverage information should be collected while executing the test
|
|
20
|
+
collectCoverage: true,
|
|
21
|
+
|
|
22
|
+
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
23
|
+
// collectCoverageFrom: undefined,
|
|
24
|
+
collectCoverageFrom: ['./src/**/*.{ts,js}'],
|
|
25
|
+
|
|
26
|
+
// The directory where Jest should output its coverage files
|
|
27
|
+
coverageDirectory: "coverage",
|
|
28
|
+
|
|
29
|
+
// An array of regexp pattern strings used to skip coverage collection
|
|
30
|
+
// coveragePathIgnorePatterns: [
|
|
31
|
+
// "/node_modules/"
|
|
32
|
+
// ],
|
|
33
|
+
|
|
34
|
+
// Indicates which provider should be used to instrument code for coverage
|
|
35
|
+
coverageProvider: "v8",
|
|
36
|
+
|
|
37
|
+
// A list of reporter names that Jest uses when writing coverage reports
|
|
38
|
+
// coverageReporters: [
|
|
39
|
+
// "json",
|
|
40
|
+
// "text",
|
|
41
|
+
// "lcov",
|
|
42
|
+
// "clover"
|
|
43
|
+
// ],
|
|
44
|
+
|
|
45
|
+
// An object that configures minimum threshold enforcement for coverage results
|
|
46
|
+
// coverageThreshold: undefined,
|
|
47
|
+
|
|
48
|
+
// A path to a custom dependency extractor
|
|
49
|
+
// dependencyExtractor: undefined,
|
|
50
|
+
|
|
51
|
+
// Make calling deprecated APIs throw helpful error messages
|
|
52
|
+
// errorOnDeprecated: false,
|
|
53
|
+
|
|
54
|
+
// The default configuration for fake timers
|
|
55
|
+
// fakeTimers: {
|
|
56
|
+
// "enableGlobally": false
|
|
57
|
+
// },
|
|
58
|
+
|
|
59
|
+
// Force coverage collection from ignored files using an array of glob patterns
|
|
60
|
+
// forceCoverageMatch: [],
|
|
61
|
+
|
|
62
|
+
// A path to a module which exports an async function that is triggered once before all test suites
|
|
63
|
+
// globalSetup: undefined,
|
|
64
|
+
|
|
65
|
+
// A path to a module which exports an async function that is triggered once after all test suites
|
|
66
|
+
// globalTeardown: undefined,
|
|
67
|
+
|
|
68
|
+
// A set of global variables that need to be available in all test environments
|
|
69
|
+
// globals: {},
|
|
70
|
+
|
|
71
|
+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
|
72
|
+
// maxWorkers: "50%",
|
|
73
|
+
|
|
74
|
+
// An array of directory names to be searched recursively up from the requiring module's location
|
|
75
|
+
// moduleDirectories: [
|
|
76
|
+
// "node_modules"
|
|
77
|
+
// ],
|
|
78
|
+
|
|
79
|
+
// An array of file extensions your modules use
|
|
80
|
+
// moduleFileExtensions: [
|
|
81
|
+
// "js",
|
|
82
|
+
// "mjs",
|
|
83
|
+
// "cjs",
|
|
84
|
+
// "jsx",
|
|
85
|
+
// "ts",
|
|
86
|
+
// "tsx",
|
|
87
|
+
// "json",
|
|
88
|
+
// "node"
|
|
89
|
+
// ],
|
|
90
|
+
|
|
91
|
+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
92
|
+
// moduleNameMapper: {},
|
|
93
|
+
|
|
94
|
+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
95
|
+
// modulePathIgnorePatterns: [],
|
|
96
|
+
|
|
97
|
+
// Activates notifications for test results
|
|
98
|
+
// notify: false,
|
|
99
|
+
|
|
100
|
+
// An enum that specifies notification mode. Requires { notify: true }
|
|
101
|
+
// notifyMode: "failure-change",
|
|
102
|
+
|
|
103
|
+
// A preset that is used as a base for Jest's configuration
|
|
104
|
+
// preset: undefined,
|
|
105
|
+
preset: 'ts-jest',
|
|
106
|
+
|
|
107
|
+
// Run tests from one or more projects
|
|
108
|
+
// projects: undefined,
|
|
109
|
+
|
|
110
|
+
// Use this configuration option to add custom reporters to Jest
|
|
111
|
+
// reporters: undefined,
|
|
112
|
+
|
|
113
|
+
// Automatically reset mock state before every test
|
|
114
|
+
// resetMocks: false,
|
|
115
|
+
|
|
116
|
+
// Reset the module registry before running each individual test
|
|
117
|
+
// resetModules: false,
|
|
118
|
+
|
|
119
|
+
// A path to a custom resolver
|
|
120
|
+
// resolver: undefined,
|
|
121
|
+
|
|
122
|
+
// Automatically restore mock state and implementation before every test
|
|
123
|
+
// restoreMocks: false,
|
|
124
|
+
|
|
125
|
+
// The root directory that Jest should scan for tests and modules within
|
|
126
|
+
// rootDir: undefined,
|
|
127
|
+
|
|
128
|
+
// A list of paths to directories that Jest should use to search for files in
|
|
129
|
+
// roots: [
|
|
130
|
+
// "<rootDir>"
|
|
131
|
+
// ],
|
|
132
|
+
|
|
133
|
+
// Allows you to use a custom runner instead of Jest's default test runner
|
|
134
|
+
// runner: "jest-runner",
|
|
135
|
+
|
|
136
|
+
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
137
|
+
// setupFiles: [],
|
|
138
|
+
|
|
139
|
+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
140
|
+
// setupFilesAfterEnv: [],
|
|
141
|
+
|
|
142
|
+
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
143
|
+
// slowTestThreshold: 5,
|
|
144
|
+
|
|
145
|
+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
146
|
+
// snapshotSerializers: [],
|
|
147
|
+
|
|
148
|
+
// The test environment that will be used for testing
|
|
149
|
+
// testEnvironment: "jest-environment-node",
|
|
150
|
+
|
|
151
|
+
// Options that will be passed to the testEnvironment
|
|
152
|
+
// testEnvironmentOptions: {},
|
|
153
|
+
|
|
154
|
+
// Adds a location field to test results
|
|
155
|
+
// testLocationInResults: false,
|
|
156
|
+
|
|
157
|
+
// The glob patterns Jest uses to detect test files
|
|
158
|
+
// testMatch: [
|
|
159
|
+
// "**/__tests__/**/*.[jt]s?(x)",
|
|
160
|
+
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
|
161
|
+
// ],
|
|
162
|
+
|
|
163
|
+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
164
|
+
// testPathIgnorePatterns: [
|
|
165
|
+
// "/node_modules/"
|
|
166
|
+
// ],
|
|
167
|
+
|
|
168
|
+
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
169
|
+
// testRegex: [],
|
|
170
|
+
|
|
171
|
+
// This option allows the use of a custom results processor
|
|
172
|
+
// testResultsProcessor: undefined,
|
|
173
|
+
|
|
174
|
+
// This option allows use of a custom test runner
|
|
175
|
+
// testRunner: "jest-circus/runner",
|
|
176
|
+
|
|
177
|
+
// A map from regular expressions to paths to transformers
|
|
178
|
+
// transform: undefined,
|
|
179
|
+
transform: {
|
|
180
|
+
'\\.[jt]sx?$': [
|
|
181
|
+
'ts-jest',
|
|
182
|
+
{
|
|
183
|
+
tsconfig: 'tsconfig.src.json',
|
|
184
|
+
diagnostics: true,
|
|
185
|
+
useESM: true,
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
191
|
+
// transformIgnorePatterns: [
|
|
192
|
+
// "/node_modules/",
|
|
193
|
+
// "\\.pnp\\.[^\\/]+$"
|
|
194
|
+
// ],
|
|
195
|
+
|
|
196
|
+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
197
|
+
// unmockedModulePathPatterns: undefined,
|
|
198
|
+
|
|
199
|
+
// Indicates whether each individual test should be reported during the run
|
|
200
|
+
// verbose: undefined,
|
|
201
|
+
|
|
202
|
+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
203
|
+
// watchPathIgnorePatterns: [],
|
|
204
|
+
|
|
205
|
+
// Whether to use watchman for file crawling
|
|
206
|
+
// watchman: true,
|
|
207
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web_plsql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"author": "Dieter Oberkofler <dieter.oberkofler@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "The Express Middleware for Oracle PL/SQL",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"homepage": "https://github.com/doberkofler/web_plsql",
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": ">=
|
|
23
|
+
"node": ">=16"
|
|
24
24
|
},
|
|
25
25
|
"maintainers": [
|
|
26
26
|
{
|
|
@@ -41,73 +41,45 @@
|
|
|
41
41
|
"eslint": "eslint --cache --report-unused-disable-directives \"./**/*.ts\"",
|
|
42
42
|
"type-check": "tsc --project ./tsconfig.json --noEmit",
|
|
43
43
|
"lint": "npm run eslint && npm run type-check",
|
|
44
|
-
"test": "
|
|
45
|
-
"test
|
|
46
|
-
"coveralls": "npm run test-cov && cat ./coverage/lcov.info | coveralls",
|
|
44
|
+
"test": "jest --coverage=false",
|
|
45
|
+
"test:coverage": "jest",
|
|
47
46
|
"sample": "node examples/sample.js",
|
|
48
47
|
"rebuild": "npm run clean && npm run lint && npm run build && npm run test",
|
|
49
48
|
"create-package": "shx rm -f *.tgz && npm pack",
|
|
50
49
|
"install": "npm run build"
|
|
51
50
|
},
|
|
52
|
-
"nyc": {
|
|
53
|
-
"include": [
|
|
54
|
-
"src/*.ts"
|
|
55
|
-
],
|
|
56
|
-
"extension": [
|
|
57
|
-
".ts"
|
|
58
|
-
],
|
|
59
|
-
"require": [
|
|
60
|
-
"ts-node/register"
|
|
61
|
-
],
|
|
62
|
-
"reporter": [
|
|
63
|
-
"text-summary",
|
|
64
|
-
"html"
|
|
65
|
-
],
|
|
66
|
-
"sourceMap": true,
|
|
67
|
-
"instrument": true,
|
|
68
|
-
"all": true
|
|
69
|
-
},
|
|
70
51
|
"dependencies": {
|
|
71
|
-
"body-parser": "1.
|
|
52
|
+
"body-parser": "1.20.0",
|
|
72
53
|
"compression": "1.7.4",
|
|
73
54
|
"connect-multiparty": "2.2.0",
|
|
74
|
-
"cookie-parser": "1.4.
|
|
55
|
+
"cookie-parser": "1.4.6",
|
|
75
56
|
"escape-html": "1.0.3",
|
|
76
|
-
"express": "4.
|
|
77
|
-
"express-status-monitor": "1.3.
|
|
78
|
-
"http-parser-js": "0.5.
|
|
57
|
+
"express": "4.18.1",
|
|
58
|
+
"express-status-monitor": "1.3.4",
|
|
59
|
+
"http-parser-js": "0.5.8",
|
|
79
60
|
"mkdirp": "1.0.4",
|
|
80
|
-
"morgan": "1.10.0"
|
|
61
|
+
"morgan": "1.10.0",
|
|
62
|
+
"oracledb": "5.5.0"
|
|
81
63
|
},
|
|
82
64
|
"devDependencies": {
|
|
83
|
-
"@types/body-parser": "1.19.
|
|
84
|
-
"@types/
|
|
85
|
-
"@types/
|
|
86
|
-
"@types/
|
|
87
|
-
"@types/
|
|
88
|
-
"@types/
|
|
89
|
-
"@types/
|
|
90
|
-
"@types/
|
|
91
|
-
"@types/
|
|
92
|
-
"@
|
|
93
|
-
"@
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"@typescript-eslint/parser": "4.21.0",
|
|
97
|
-
"chai": "4.3.4",
|
|
98
|
-
"coveralls": "3.1.0",
|
|
99
|
-
"eslint": "7.23.0",
|
|
100
|
-
"istanbul": "1.1.0-alpha.1",
|
|
101
|
-
"mocha": "8.3.2",
|
|
102
|
-
"nyc": "15.1.0",
|
|
65
|
+
"@types/body-parser": "1.19.2",
|
|
66
|
+
"@types/compression": "1.7.2",
|
|
67
|
+
"@types/cookie-parser": "1.4.3",
|
|
68
|
+
"@types/escape-html": "1.0.2",
|
|
69
|
+
"@types/mkdirp": "1.0.2",
|
|
70
|
+
"@types/morgan": "1.9.3",
|
|
71
|
+
"@types/node": "18.7.16",
|
|
72
|
+
"@types/oracledb": "5.2.3",
|
|
73
|
+
"@types/supertest": "2.0.12",
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "5.36.2",
|
|
75
|
+
"@typescript-eslint/parser": "5.36.2",
|
|
76
|
+
"eslint": "8.23.0",
|
|
77
|
+
"jest": "29.0.3",
|
|
103
78
|
"rimraf": "3.0.2",
|
|
104
|
-
"shx": "0.3.
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"ts-node": "9.1
|
|
108
|
-
"typescript": "4.
|
|
109
|
-
},
|
|
110
|
-
"optionalDependencies": {
|
|
111
|
-
"oracledb": "5.1.0"
|
|
79
|
+
"shx": "0.3.4",
|
|
80
|
+
"supertest": "6.2.4",
|
|
81
|
+
"ts-jest": "29.0.0",
|
|
82
|
+
"ts-node": "10.9.1",
|
|
83
|
+
"typescript": "4.8.3"
|
|
112
84
|
}
|
|
113
85
|
}
|
package/src/cgi.ts
CHANGED
|
@@ -26,7 +26,7 @@ export function getCGI(req: express.Request, options: oracleExpressMiddleware$op
|
|
|
26
26
|
'GATEWAY_IVERSION': '2',
|
|
27
27
|
'SERVER_SOFTWARE': 'web_plsql',
|
|
28
28
|
'GATEWAY_INTERFACE': 'CGI/1.1',
|
|
29
|
-
'SERVER_PORT': req.socket.localPort.toString(),
|
|
29
|
+
'SERVER_PORT': typeof req.socket.localPort === 'number' ? req.socket.localPort.toString() : '',
|
|
30
30
|
'SERVER_NAME': os.hostname(),
|
|
31
31
|
'REQUEST_METHOD': req.method,
|
|
32
32
|
'PATH_INFO': req.params.name,
|
package/src/errorPage.ts
CHANGED
|
@@ -21,7 +21,7 @@ type outputType = {html: string; text: string};
|
|
|
21
21
|
* @param {Trace} trace - Tracing object.
|
|
22
22
|
* @param {Error} error - The error.
|
|
23
23
|
*/
|
|
24
|
-
export function errorPage(req: express.Request, res: express.Response, options: oracleExpressMiddleware$options, trace: Trace, error:
|
|
24
|
+
export function errorPage(req: express.Request, res: express.Response, options: oracleExpressMiddleware$options, trace: Trace, error: unknown): void {
|
|
25
25
|
let output = {
|
|
26
26
|
html: '',
|
|
27
27
|
text: ''
|
|
@@ -30,14 +30,16 @@ export function errorPage(req: express.Request, res: express.Response, options:
|
|
|
30
30
|
// get the error description
|
|
31
31
|
try {
|
|
32
32
|
output = getError(req, error);
|
|
33
|
-
} catch (
|
|
33
|
+
} catch (err) {
|
|
34
34
|
/* istanbul ignore next */
|
|
35
35
|
const header = 'ERROR';
|
|
36
|
+
|
|
36
37
|
/* istanbul ignore next */
|
|
37
|
-
const message = `${
|
|
38
|
+
const message = err instanceof Error ? `${err.message}\n${err.stack}` : JSON.stringify(err);
|
|
38
39
|
|
|
39
40
|
/* istanbul ignore next */
|
|
40
41
|
output.html += getHeaderHtml(header) + getHtml(message);
|
|
42
|
+
|
|
41
43
|
/* istanbul ignore next */
|
|
42
44
|
output.text += getHeaderHtml(header) + getHtml(message);
|
|
43
45
|
}
|
|
@@ -59,7 +61,7 @@ export function errorPage(req: express.Request, res: express.Response, options:
|
|
|
59
61
|
/*
|
|
60
62
|
* Show an error page
|
|
61
63
|
*/
|
|
62
|
-
function getError(req: express.Request, error:
|
|
64
|
+
function getError(req: express.Request, error: unknown): outputType {
|
|
63
65
|
let timestamp: Date = new Date();
|
|
64
66
|
let message: string = '';
|
|
65
67
|
let environment: environmentType | null = null;
|
|
@@ -89,9 +91,9 @@ function getError(req: express.Request, error: Error): outputType {
|
|
|
89
91
|
try {
|
|
90
92
|
/* istanbul ignore next */
|
|
91
93
|
new Error(); // eslint-disable-line no-new
|
|
92
|
-
} catch (
|
|
94
|
+
} catch (err) {
|
|
93
95
|
/* istanbul ignore next */
|
|
94
|
-
message +=
|
|
96
|
+
message += err instanceof Error ? err.stack : '';
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
|
|
@@ -163,11 +165,12 @@ function getProcedure(output: outputType, sql: string, bind: any) {
|
|
|
163
165
|
text += name + ': ' + value + '\n';
|
|
164
166
|
});
|
|
165
167
|
}
|
|
166
|
-
} catch (
|
|
168
|
+
} catch (err) {
|
|
167
169
|
/* istanbul ignore next */
|
|
168
|
-
output.html +=
|
|
170
|
+
output.html += err instanceof Error ? err.toString() : 'ERROR';
|
|
171
|
+
|
|
169
172
|
/* istanbul ignore next */
|
|
170
|
-
output.text +=
|
|
173
|
+
output.text += err instanceof Error ? err.toString() : 'ERROR';
|
|
171
174
|
/* istanbul ignore next */
|
|
172
175
|
return;
|
|
173
176
|
}
|
|
@@ -190,11 +193,13 @@ function getEnvironment(output: outputType, environment: environmentType) {
|
|
|
190
193
|
html += `<tr><td>${key}:</td><td>${environment[key]}</td></tr>`;
|
|
191
194
|
text += key + '=' + environment[key] + '\n';
|
|
192
195
|
}
|
|
193
|
-
} catch (
|
|
196
|
+
} catch (err) {
|
|
194
197
|
/* istanbul ignore next */
|
|
195
|
-
output.html +=
|
|
198
|
+
output.html += err instanceof Error ? err.toString() : 'ERROR';
|
|
199
|
+
|
|
196
200
|
/* istanbul ignore next */
|
|
197
|
-
output.text +=
|
|
201
|
+
output.text += err instanceof Error ? err.toString() : 'ERROR';
|
|
202
|
+
|
|
198
203
|
/* istanbul ignore next */
|
|
199
204
|
return;
|
|
200
205
|
}
|
package/src/fileUpload.ts
CHANGED
|
@@ -90,9 +90,9 @@ export function uploadFile(file: fileUploadType, docTableName: string, databaseC
|
|
|
90
90
|
let blobContent;
|
|
91
91
|
try {
|
|
92
92
|
blobContent = fs.readFileSync(file.physicalFilename);
|
|
93
|
-
} catch (
|
|
93
|
+
} catch (err) {
|
|
94
94
|
/* istanbul ignore next */
|
|
95
|
-
reject(new Error(`Unable to read file "${file.physicalFilename}"\n
|
|
95
|
+
reject(new Error(`Unable to read file "${file.physicalFilename}"\n${err instanceof Error ? err.toString() : ''}`));
|
|
96
96
|
/* istanbul ignore next */
|
|
97
97
|
return;
|
|
98
98
|
}
|
package/src/index.ts
CHANGED
|
@@ -58,8 +58,8 @@ function requestHandler(req: express.Request, res: express.Response, databasePoo
|
|
|
58
58
|
errorPage(req, res, options, trace, e);
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
} catch (
|
|
61
|
+
} catch (err) {
|
|
62
62
|
/* istanbul ignore next */
|
|
63
|
-
errorPage(req, res, options, trace,
|
|
63
|
+
errorPage(req, res, options, trace, err);
|
|
64
64
|
}
|
|
65
65
|
}
|
package/src/procedure.ts
CHANGED
|
@@ -81,9 +81,9 @@ export async function invokeProcedure(req: express.Request, res: express.Respons
|
|
|
81
81
|
trace.write(`execute:\n${'-'.repeat(30)}\n${sqlStatement}\n${'-'.repeat(30)}\nwith bindings:\n${Trace.inspect(bind)}`);
|
|
82
82
|
result = await databaseConnection.execute(sqlStatement, Object.assign(bind, para.bind));
|
|
83
83
|
trace.write(`results:\n${Trace.inspect(result)}`);
|
|
84
|
-
} catch (
|
|
84
|
+
} catch (err) {
|
|
85
85
|
/* istanbul ignore next */
|
|
86
|
-
throwError(`Error when executing procedure\n${sqlStatement}\n${
|
|
86
|
+
throwError(`Error when executing procedure\n${sqlStatement}\n${err instanceof Error ? err.toString() : ''}`, para, cgiObj, trace);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
//
|
|
@@ -332,9 +332,9 @@ async function getArguments(procedure: string, databaseConnection: oracledb.Conn
|
|
|
332
332
|
|
|
333
333
|
try {
|
|
334
334
|
result = await databaseConnection.execute<{names: Array<string>; types: Array<string>}>(sql.join('\n'), bind);
|
|
335
|
-
} catch (
|
|
335
|
+
} catch (err) {
|
|
336
336
|
/* istanbul ignore next */
|
|
337
|
-
const message = `Error when retrieving arguments\n${sql.join('\n')}\n${
|
|
337
|
+
const message = `Error when retrieving arguments\n${sql.join('\n')}\n${err instanceof Error ? err.stack : ''}`;
|
|
338
338
|
/* istanbul ignore next */
|
|
339
339
|
throw new RequestError(message);
|
|
340
340
|
}
|
package/src/procedureError.ts
CHANGED
|
@@ -8,9 +8,9 @@ export class ProcedureError extends Error {
|
|
|
8
8
|
timestamp: Date;
|
|
9
9
|
environment: environmentType;
|
|
10
10
|
sql: string;
|
|
11
|
-
bind:
|
|
11
|
+
bind: unknown;
|
|
12
12
|
|
|
13
|
-
constructor(message: string, environment: environmentType, sql: string, bind:
|
|
13
|
+
constructor(message: string, environment: environmentType, sql: string, bind: unknown) {
|
|
14
14
|
super(message);
|
|
15
15
|
|
|
16
16
|
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
package/src/request.ts
CHANGED
|
@@ -32,18 +32,18 @@ export async function processRequest(req: express.Request, res: express.Response
|
|
|
32
32
|
try {
|
|
33
33
|
databasePool = await databasePoolPromise;
|
|
34
34
|
trace.write('processRequest: Connection pool has been allocated');
|
|
35
|
-
} catch (
|
|
35
|
+
} catch (err) {
|
|
36
36
|
/* istanbul ignore next */
|
|
37
|
-
throw new RequestError(`Unable to create database pool.\n${
|
|
37
|
+
throw new RequestError(`Unable to create database pool.\n${err instanceof Error ? err.message : ''}`);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// open database connection
|
|
41
41
|
try {
|
|
42
42
|
databaseConnection = await databasePool.getConnection();
|
|
43
43
|
trace.write('processRequest: Connection has been allocated');
|
|
44
|
-
} catch (
|
|
44
|
+
} catch (err) {
|
|
45
45
|
/* istanbul ignore next */
|
|
46
|
-
throw new RequestError(`Unable to open database connection\n${
|
|
46
|
+
throw new RequestError(`Unable to open database connection\n${err instanceof Error ? err.message: ''}`);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// execute request
|
|
@@ -53,9 +53,9 @@ export async function processRequest(req: express.Request, res: express.Response
|
|
|
53
53
|
try {
|
|
54
54
|
await databaseConnection.release();
|
|
55
55
|
trace.write('processRequest: Connection has been released');
|
|
56
|
-
} catch (
|
|
56
|
+
} catch (err) {
|
|
57
57
|
/* istanbul ignore next */
|
|
58
|
-
console.error(`Unable to release database connection\n${
|
|
58
|
+
console.error(`Unable to release database connection\n${err instanceof Error ? err.message : ''}`);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
trace.write('processRequest: EXIT');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {getCGI} from '
|
|
1
|
+
import {describe, it, expect} from '@jest/globals';
|
|
2
|
+
import {getCGI} from '../../src/cgi';
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import os from 'os';
|
|
5
|
-
import type {oracleExpressMiddleware$options} from '
|
|
5
|
+
import type {oracleExpressMiddleware$options} from '../../src/config';
|
|
6
6
|
|
|
7
7
|
describe('cgi', () => {
|
|
8
8
|
it('with a proper configuration object and request', () => {
|
|
@@ -59,9 +59,9 @@ describe('cgi', () => {
|
|
|
59
59
|
|
|
60
60
|
const cgi = getCGI(req as unknown as express.Request, options as unknown as oracleExpressMiddleware$options);
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
expect(Object.keys(cgi)).toHaveLength(29);
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
expect(cgi).toStrictEqual({
|
|
65
65
|
'PLSQL_GATEWAY': 'WebDb',
|
|
66
66
|
'GATEWAY_IVERSION': '2',
|
|
67
67
|
'SERVER_SOFTWARE': 'web_plsql',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {validate} from '
|
|
1
|
+
import {describe, it, expect} from '@jest/globals';
|
|
2
|
+
import {validate} from '../../src/config';
|
|
3
3
|
|
|
4
4
|
describe('configuration options', () => {
|
|
5
5
|
it('should allow the following options', () => {
|
|
@@ -10,7 +10,7 @@ describe('configuration options', () => {
|
|
|
10
10
|
{pathAlias: {alias: 'r', procedure: 'p'}},
|
|
11
11
|
{errorStyle: 'debug'}
|
|
12
12
|
].forEach(options => {
|
|
13
|
-
|
|
13
|
+
expect(typeof validate(options as unknown as Record<string, unknown>)).toBe('object');
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
});
|
|
@@ -33,9 +33,9 @@ describe('configuration errors', () => {
|
|
|
33
33
|
{config: {trace: 'enabled'}, error: 'The optional option "trace" must be "on" or "off"'},
|
|
34
34
|
].forEach(test => {
|
|
35
35
|
it(`should throw the exception "${test.error}"`, () => {
|
|
36
|
-
|
|
36
|
+
expect(() => {
|
|
37
37
|
validate(test.config as unknown as Record<string, unknown>);
|
|
38
|
-
}
|
|
38
|
+
}).toThrow(test.error);
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {describe, beforeAll, afterAll, it, expect} from '@jest/globals';
|
|
2
|
+
import {errorPage} from '../../src/errorPage';
|
|
3
|
+
import {RequestError} from '../../src/requestError';
|
|
4
|
+
import {ProcedureError} from '../../src/procedureError';
|
|
5
|
+
import {oracleExpressMiddleware$options} from '../../src/config';
|
|
6
|
+
|
|
7
|
+
describe('errorPage', () => {
|
|
8
|
+
let errorSave: any;
|
|
9
|
+
|
|
10
|
+
beforeAll(() => {
|
|
11
|
+
errorSave = console.error;
|
|
12
|
+
console.error = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterAll(() => {
|
|
16
|
+
console.error = errorSave;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
let errorText = '';
|
|
20
|
+
let errorHtml = '';
|
|
21
|
+
|
|
22
|
+
const options: oracleExpressMiddleware$options = {
|
|
23
|
+
errorStyle: 'debug',
|
|
24
|
+
trace: 'off'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const req: any = {};
|
|
28
|
+
const res: any = {
|
|
29
|
+
status() {
|
|
30
|
+
return this;
|
|
31
|
+
},
|
|
32
|
+
send(error: string) {
|
|
33
|
+
errorHtml = error;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const trace: any = {
|
|
38
|
+
write(error: string) {
|
|
39
|
+
errorText = error;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
it('should report a "error message" in text and html format', () => {
|
|
44
|
+
errorPage(req, res, options, trace, new Error('error message'));
|
|
45
|
+
|
|
46
|
+
expect(/error message/.test(errorText)).toBeTruthy();
|
|
47
|
+
expect(/ERROR/.test(errorText)).toBeTruthy();
|
|
48
|
+
expect(/REQUEST/.test(errorText)).toBeTruthy();
|
|
49
|
+
expect(/error message/.test(errorHtml)).toBeTruthy();
|
|
50
|
+
expect(/TIMESTAMP/.test(errorHtml)).toBeTruthy();
|
|
51
|
+
expect(/ERROR/.test(errorHtml)).toBeTruthy();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should report a "Error" in text and html format', () => {
|
|
55
|
+
errorPage(req, res, options, trace, new Error('throw Error'));
|
|
56
|
+
|
|
57
|
+
expect(/throw Error/.test(errorText)).toBeTruthy();
|
|
58
|
+
expect(/ERROR/.test(errorText)).toBeTruthy();
|
|
59
|
+
expect(/REQUEST/.test(errorText)).toBeTruthy();
|
|
60
|
+
expect(/throw Error/.test(errorHtml)).toBeTruthy();
|
|
61
|
+
expect(/TIMESTAMP/.test(errorHtml)).toBeTruthy();
|
|
62
|
+
expect(/ERROR/.test(errorHtml)).toBeTruthy();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should report a "RequestError" in text and html format', () => {
|
|
66
|
+
errorPage(req, res, options, trace, new RequestError('throw RequestError'));
|
|
67
|
+
|
|
68
|
+
expect(/throw RequestError/.test(errorText)).toBeTruthy();
|
|
69
|
+
expect(/ERROR/.test(errorText)).toBeTruthy();
|
|
70
|
+
expect(/REQUEST/.test(errorText)).toBeTruthy();
|
|
71
|
+
expect(/throw RequestError/.test(errorHtml)).toBeTruthy();
|
|
72
|
+
expect(/TIMESTAMP/.test(errorHtml)).toBeTruthy();
|
|
73
|
+
expect(/ERROR/.test(errorHtml)).toBeTruthy();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should report a "ProcedureError" in text and html format', () => {
|
|
77
|
+
const environment = {dad: 'dad'};
|
|
78
|
+
const sql = 'sql';
|
|
79
|
+
const bind = {p1: '1'};
|
|
80
|
+
|
|
81
|
+
errorPage(req, res, options, trace, new ProcedureError('throw ProcedureError', environment, sql, bind));
|
|
82
|
+
|
|
83
|
+
expect(/throw ProcedureError/.test(errorText)).toBeTruthy();
|
|
84
|
+
expect(/ERROR/.test(errorText)).toBeTruthy();
|
|
85
|
+
expect(/REQUEST/.test(errorText)).toBeTruthy();
|
|
86
|
+
expect(/PROCEDURE/.test(errorText)).toBeTruthy();
|
|
87
|
+
expect(/ENVIRONMENT/.test(errorText)).toBeTruthy();
|
|
88
|
+
expect(/throw ProcedureError/.test(errorHtml)).toBeTruthy();
|
|
89
|
+
expect(/TIMESTAMP/.test(errorHtml)).toBeTruthy();
|
|
90
|
+
expect(/ERROR/.test(errorHtml)).toBeTruthy();
|
|
91
|
+
expect(/PROCEDURE/.test(errorHtml)).toBeTruthy();
|
|
92
|
+
expect(/ENVIRONMENT/.test(errorHtml)).toBeTruthy();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should only report a "404" error when in basic mode', () => {
|
|
96
|
+
options.errorStyle = 'basic';
|
|
97
|
+
errorPage(req, res, options, trace, new Error('error message'));
|
|
98
|
+
|
|
99
|
+
expect(/error message/.test(errorText)).toBeTruthy();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {setExecuteCallback, createPool, Connection, getConnection, ConnectionPool, Lob, BLOB} from '
|
|
1
|
+
import {describe, beforeEach, it, expect} from '@jest/globals';
|
|
2
|
+
import {setExecuteCallback, createPool, Connection, getConnection, ConnectionPool, Lob, BLOB} from '../mock/oracledb';
|
|
3
3
|
|
|
4
4
|
describe('oracledb', () => {
|
|
5
5
|
it('createPool', async () => {
|
|
6
6
|
const connectionPool = await _createPool();
|
|
7
|
-
|
|
7
|
+
expect(connectionPool).toBeInstanceOf(ConnectionPool);
|
|
8
8
|
return connectionPool;
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
it('getConnection', async () => {
|
|
12
12
|
const connection = await _getConnection();
|
|
13
|
-
|
|
13
|
+
expect(connection).toBeInstanceOf(Connection);
|
|
14
14
|
return connection;
|
|
15
15
|
});
|
|
16
16
|
});
|
|
@@ -20,7 +20,7 @@ describe('ConnectionPool', () => {
|
|
|
20
20
|
const connectionPool = await _createPool();
|
|
21
21
|
const connection = await connectionPool.getConnection();
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
expect(connection).toBeInstanceOf(Connection);
|
|
24
24
|
|
|
25
25
|
return connection;
|
|
26
26
|
});
|
|
@@ -34,14 +34,14 @@ describe('ConnectionPool', () => {
|
|
|
34
34
|
describe('Connection', () => {
|
|
35
35
|
it('getConnection', async () => {
|
|
36
36
|
const connection = await _getConnection();
|
|
37
|
-
|
|
37
|
+
expect(connection).toBeInstanceOf(Connection);
|
|
38
38
|
return connection;
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
it('createLob', async () => {
|
|
42
42
|
const connection = await _getConnection();
|
|
43
43
|
const lob = await connection.createLob(BLOB);
|
|
44
|
-
|
|
44
|
+
expect(lob).toBeInstanceOf(Lob);
|
|
45
45
|
return lob;
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -58,7 +58,7 @@ describe('Connection.execute', () => {
|
|
|
58
58
|
|
|
59
59
|
it('execute', async () => {
|
|
60
60
|
const connection = await _getConnection();
|
|
61
|
-
|
|
61
|
+
expect(await connection.execute('select * from dual')).toStrictEqual({});
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
it('execute with execution callback', async () => {
|
|
@@ -67,11 +67,11 @@ describe('Connection.execute', () => {
|
|
|
67
67
|
|
|
68
68
|
// register an execute callback
|
|
69
69
|
setExecuteCallback((sql: string) => {
|
|
70
|
-
|
|
70
|
+
expect(sql).toBe(SQL);
|
|
71
71
|
return {sql: SQL};
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
expect(await connection.execute(SQL)).toStrictEqual({sql: SQL});
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {describe, beforeAll, afterAll, beforeEach, it, expect} from '@jest/globals';
|
|
2
2
|
import util from 'util';
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import http from 'http';
|
|
@@ -10,9 +10,9 @@ import multipart from 'connect-multiparty';
|
|
|
10
10
|
import cookieParser from 'cookie-parser';
|
|
11
11
|
import compression from 'compression';
|
|
12
12
|
import request from 'supertest';
|
|
13
|
-
import {setExecuteCallback, createPool} from '
|
|
13
|
+
import {setExecuteCallback, createPool} from '../mock/oracledb';
|
|
14
14
|
|
|
15
|
-
const webplsql = require('
|
|
15
|
+
const webplsql = require('../../src/index'); // eslint-disable-line @typescript-eslint/no-var-requires
|
|
16
16
|
|
|
17
17
|
const PORT = 8765;
|
|
18
18
|
const PATH = '/base';
|
|
@@ -29,10 +29,10 @@ describe('server utilities', () => {
|
|
|
29
29
|
it('should start a server', async () => {
|
|
30
30
|
const serverConfig = await serverStart();
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//
|
|
32
|
+
expect(Object.prototype.toString.call(serverConfig)).toBe('[object Object]');
|
|
33
|
+
expect(Object.prototype.toString.call(serverConfig.app.listen)).toBe('[object Function]');
|
|
34
|
+
expect(Object.prototype.toString.call(serverConfig.server)).toBe('[object Object]');
|
|
35
|
+
//expect(serverConfig.connectionPool).toBeInstanceOf(oracledb.Pool);
|
|
36
36
|
|
|
37
37
|
await serverStop(serverConfig);
|
|
38
38
|
});
|
|
@@ -41,15 +41,15 @@ describe('server utilities', () => {
|
|
|
41
41
|
describe('server static', () => {
|
|
42
42
|
let serverConfig: any;
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
beforeAll(async () => {
|
|
45
45
|
serverConfig = await serverStart();
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
afterAll(async () => {
|
|
49
49
|
await serverStop(serverConfig);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
beforeEach(
|
|
52
|
+
beforeEach(() => {
|
|
53
53
|
setExecuteCallback();
|
|
54
54
|
});
|
|
55
55
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {streamToBuffer} from '
|
|
1
|
+
import {describe, it, expect} from '@jest/globals';
|
|
2
|
+
import {streamToBuffer} from '../../src/stream';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
|
|
5
5
|
describe('stream', () => {
|
|
@@ -14,7 +14,7 @@ describe('stream', () => {
|
|
|
14
14
|
const readStream = fs.createReadStream('file.tmp');
|
|
15
15
|
const readBuffer = await streamToBuffer(readStream);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
expect(buffer.equals(readBuffer)).toBeTruthy();
|
|
18
18
|
|
|
19
19
|
fs.unlinkSync(filename);
|
|
20
20
|
});
|
package/test/errorPage.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {assert} from 'chai';
|
|
2
|
-
import {errorPage} from '../src/errorPage';
|
|
3
|
-
import {RequestError} from '../src/requestError';
|
|
4
|
-
import {ProcedureError} from '../src/procedureError';
|
|
5
|
-
import {oracleExpressMiddleware$options} from '../src/config';
|
|
6
|
-
|
|
7
|
-
describe('errorPage', () => {
|
|
8
|
-
let errorSave: any;
|
|
9
|
-
|
|
10
|
-
before(() => {
|
|
11
|
-
errorSave = console.error;
|
|
12
|
-
console.error = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
after(() => {
|
|
16
|
-
console.error = errorSave;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
let errorText = '';
|
|
20
|
-
let errorHtml = '';
|
|
21
|
-
|
|
22
|
-
const options: oracleExpressMiddleware$options = {
|
|
23
|
-
errorStyle: 'debug',
|
|
24
|
-
trace: 'off'
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const req: any = {};
|
|
28
|
-
const res: any = {
|
|
29
|
-
status() {
|
|
30
|
-
return this;
|
|
31
|
-
},
|
|
32
|
-
send(error: string) {
|
|
33
|
-
errorHtml = error;
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const trace: any = {
|
|
38
|
-
write(error: string) {
|
|
39
|
-
errorText = error;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
it('should report a "error message" in text and html format', () => {
|
|
44
|
-
errorPage(req, res, options, trace, new Error('error message'));
|
|
45
|
-
|
|
46
|
-
assert.isTrue(/error message/.test(errorText), 'text: error message');
|
|
47
|
-
assert.isTrue(/ERROR/.test(errorText), 'text: ERROR');
|
|
48
|
-
assert.isTrue(/REQUEST/.test(errorText), 'text: REQUEST');
|
|
49
|
-
assert.isTrue(/error message/.test(errorHtml), 'html: error message');
|
|
50
|
-
assert.isTrue(/TIMESTAMP/.test(errorHtml), 'html: TIMESTAMP');
|
|
51
|
-
assert.isTrue(/ERROR/.test(errorHtml), 'html: ERROR');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should report a "Error" in text and html format', () => {
|
|
55
|
-
errorPage(req, res, options, trace, new Error('throw Error'));
|
|
56
|
-
|
|
57
|
-
assert.isTrue(/throw Error/.test(errorText), 'text: exception message');
|
|
58
|
-
assert.isTrue(/ERROR/.test(errorText), 'text: ERROR');
|
|
59
|
-
assert.isTrue(/REQUEST/.test(errorText), 'text: REQUEST');
|
|
60
|
-
assert.isTrue(/throw Error/.test(errorHtml), 'html: exception message');
|
|
61
|
-
assert.isTrue(/TIMESTAMP/.test(errorHtml), 'html: TIMESTAMP');
|
|
62
|
-
assert.isTrue(/ERROR/.test(errorHtml), 'html: ERROR');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should report a "RequestError" in text and html format', () => {
|
|
66
|
-
errorPage(req, res, options, trace, new RequestError('throw RequestError'));
|
|
67
|
-
|
|
68
|
-
assert.isTrue(/throw RequestError/.test(errorText), 'text: exception message');
|
|
69
|
-
assert.isTrue(/ERROR/.test(errorText), 'text: ERROR');
|
|
70
|
-
assert.isTrue(/REQUEST/.test(errorText), 'text: REQUEST');
|
|
71
|
-
assert.isTrue(/throw RequestError/.test(errorHtml), 'html: exception message');
|
|
72
|
-
assert.isTrue(/TIMESTAMP/.test(errorHtml), 'html: TIMESTAMP');
|
|
73
|
-
assert.isTrue(/ERROR/.test(errorHtml), 'html: ERROR');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should report a "ProcedureError" in text and html format', () => {
|
|
77
|
-
const environment = {dad: 'dad'};
|
|
78
|
-
const sql = 'sql';
|
|
79
|
-
const bind = {p1: '1'};
|
|
80
|
-
|
|
81
|
-
errorPage(req, res, options, trace, new ProcedureError('throw ProcedureError', environment, sql, bind));
|
|
82
|
-
|
|
83
|
-
assert.isTrue(/throw ProcedureError/.test(errorText), 'text: exception message');
|
|
84
|
-
assert.isTrue(/ERROR/.test(errorText), 'text: ERROR');
|
|
85
|
-
assert.isTrue(/REQUEST/.test(errorText), 'text: REQUEST');
|
|
86
|
-
assert.isTrue(/PROCEDURE/.test(errorText), 'text: PROCEDURE');
|
|
87
|
-
assert.isTrue(/ENVIRONMENT/.test(errorText), 'text: ENVIRONMENT');
|
|
88
|
-
assert.isTrue(/throw ProcedureError/.test(errorHtml), 'html: exception message');
|
|
89
|
-
assert.isTrue(/TIMESTAMP/.test(errorHtml), 'html: TIMESTAMP');
|
|
90
|
-
assert.isTrue(/ERROR/.test(errorHtml), 'html: ERROR');
|
|
91
|
-
assert.isTrue(/PROCEDURE/.test(errorHtml), 'html: REQUEST');
|
|
92
|
-
assert.isTrue(/ENVIRONMENT/.test(errorHtml), 'text: ENVIRONMENT');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should only report a "404" error when in basic mode', () => {
|
|
96
|
-
options.errorStyle = 'basic';
|
|
97
|
-
errorPage(req, res, options, trace, new Error('error message'));
|
|
98
|
-
|
|
99
|
-
assert.isTrue(/error message/.test(errorText), 'Page not found');
|
|
100
|
-
});
|
|
101
|
-
});
|
package/tsconfig.test.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"skipLibCheck": true,
|
|
4
|
-
"moduleResolution": "node",
|
|
5
|
-
"baseUrl": ".",
|
|
6
|
-
"outDir": "lib",
|
|
7
|
-
"target": "es6",
|
|
8
|
-
"lib": [
|
|
9
|
-
"es2015",
|
|
10
|
-
"es2016",
|
|
11
|
-
"es2017",
|
|
12
|
-
"es2018"
|
|
13
|
-
],
|
|
14
|
-
"module": "commonjs",
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"strict": true,
|
|
17
|
-
"alwaysStrict": true,
|
|
18
|
-
"esModuleInterop": true
|
|
19
|
-
}
|
|
20
|
-
}
|