@trojs/openapi-server 1.7.3 → 1.7.4
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/package.json +8 -15
- package/src/api.js +2 -2
- package/src/error-status.js +2 -2
- package/src/express-callback.js +2 -4
- package/src/operation-ids.js +1 -1
- package/src/server.js +2 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trojs/openapi-server",
|
|
3
3
|
"description": "OpenAPI Server",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.4",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Pieter Wigboldus",
|
|
7
7
|
"url": "https://trojs.org/"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"lint:report": "eslint src/*.js -f json -o report.json",
|
|
13
13
|
"lint:fix": "eslint --fix",
|
|
14
14
|
"lint:rules": "eslint --print-config src/index.js > eslintconfig.json",
|
|
15
|
-
"test": "
|
|
15
|
+
"test": "node --test --experimental-test-coverage --test-reporter=spec --test-reporter=lcov --test-reporter-destination=stdout --test-reporter-destination=./coverage/lcov.info",
|
|
16
16
|
"cpd": "node_modules/jscpd/bin/jscpd src",
|
|
17
17
|
"vulnerabilities": "npm audit --omit=dev"
|
|
18
18
|
},
|
|
@@ -35,20 +35,13 @@
|
|
|
35
35
|
"main": "src/server.js",
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@eslint/js": "^9.15.0",
|
|
38
|
-
"@
|
|
39
|
-
"@stylistic/eslint-plugin-js": "^3.0.0",
|
|
40
|
-
"@trojs/lint": "^0.2.3",
|
|
41
|
-
"@types/express-serve-static-core": "^4.17.41",
|
|
38
|
+
"@trojs/lint": "^0.2.9",
|
|
42
39
|
"@types/node": "^22.0.0",
|
|
43
|
-
"
|
|
40
|
+
"@types/express-serve-static-core": "^4.17.41",
|
|
44
41
|
"eslint": "^9.15.0",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"eslint-plugin-promise": "^7.1.0",
|
|
49
|
-
"eslint-plugin-sonarjs": "^2.0.4",
|
|
50
|
-
"globals": "^15.12.0",
|
|
51
|
-
"jscpd": "^4.0.0",
|
|
42
|
+
"globals": "^16.0.0",
|
|
43
|
+
"jscpd": "^4.0.5",
|
|
44
|
+
"prettier": "^3.3.3",
|
|
52
45
|
"supertest": "^7.0.0"
|
|
53
46
|
},
|
|
54
47
|
"repository": {
|
|
@@ -56,7 +49,7 @@
|
|
|
56
49
|
"url": "https://github.com/trojs/openapi-server"
|
|
57
50
|
},
|
|
58
51
|
"engines": {
|
|
59
|
-
"node": ">= 20"
|
|
52
|
+
"node": ">= 20 < 21 || >= 22 < 23"
|
|
60
53
|
},
|
|
61
54
|
"keywords": [
|
|
62
55
|
"openapi",
|
package/src/api.js
CHANGED
|
@@ -42,7 +42,7 @@ export class Api {
|
|
|
42
42
|
* @class
|
|
43
43
|
* @param {ApiSchema} params
|
|
44
44
|
*/
|
|
45
|
-
constructor({
|
|
45
|
+
constructor ({
|
|
46
46
|
version,
|
|
47
47
|
specification,
|
|
48
48
|
controllers,
|
|
@@ -74,7 +74,7 @@ export class Api {
|
|
|
74
74
|
this.customizeAjv = customizeAjv
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
setup() {
|
|
77
|
+
setup () {
|
|
78
78
|
const router = express.Router()
|
|
79
79
|
|
|
80
80
|
if (this.swagger) {
|
package/src/error-status.js
CHANGED
|
@@ -19,6 +19,6 @@ const errorCodesStatus = [
|
|
|
19
19
|
* @param {Error} error
|
|
20
20
|
* @returns {number}
|
|
21
21
|
*/
|
|
22
|
-
export default error =>
|
|
23
|
-
errorCodesStatus.find(errorCode => error instanceof errorCode.type)
|
|
22
|
+
export default (error) =>
|
|
23
|
+
errorCodesStatus.find((errorCode) => error instanceof errorCode.type)
|
|
24
24
|
.status
|
package/src/express-callback.js
CHANGED
|
@@ -61,14 +61,12 @@ export const makeExpressCallback
|
|
|
61
61
|
})
|
|
62
62
|
|
|
63
63
|
return responseBody
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
64
|
+
} catch (error) {
|
|
66
65
|
const errorCodeStatus = getStatusByError(error)
|
|
67
66
|
|
|
68
67
|
if (errorCodeStatus >= 500) {
|
|
69
68
|
logger.error(error)
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
69
|
+
} else {
|
|
72
70
|
logger.warn(error)
|
|
73
71
|
}
|
|
74
72
|
|
package/src/operation-ids.js
CHANGED
|
@@ -8,7 +8,7 @@ const operations = ['get', 'put', 'patch', 'post', 'delete']
|
|
|
8
8
|
*/
|
|
9
9
|
export const operationIds = ({ specification }) =>
|
|
10
10
|
Object.values(specification.paths)
|
|
11
|
-
.map(path =>
|
|
11
|
+
.map((path) =>
|
|
12
12
|
Object.entries(path).map(([operation, data]) =>
|
|
13
13
|
operations.includes(operation) ? data.operationId : null
|
|
14
14
|
)
|
package/src/server.js
CHANGED
|
@@ -14,7 +14,7 @@ import { Api } from './api.js'
|
|
|
14
14
|
* @param {string} origin
|
|
15
15
|
* @returns {{ crossOriginResourcePolicy: { policy: string, directives: object } }}
|
|
16
16
|
*/
|
|
17
|
-
const getOriginResourcePolicy = origin => ({
|
|
17
|
+
const getOriginResourcePolicy = (origin) => ({
|
|
18
18
|
crossOriginResourcePolicy: {
|
|
19
19
|
policy: origin === '*' ? 'cross-origin' : 'same-origin',
|
|
20
20
|
directives: {
|
|
@@ -104,7 +104,7 @@ export const setupServer = async ({
|
|
|
104
104
|
app.use(compression())
|
|
105
105
|
app.use(helmet(getOriginResourcePolicy(origin)))
|
|
106
106
|
app.use(express.json({ limit: maximumBodySize }))
|
|
107
|
-
middleware.forEach(fn => app.use(fn))
|
|
107
|
+
middleware.forEach((fn) => app.use(fn))
|
|
108
108
|
app.use(bodyParser.urlencoded({ extended: false, limit: maximumBodySize }))
|
|
109
109
|
app.use((_request, response, next) => {
|
|
110
110
|
response.setHeader('X-Powered-By', poweredBy)
|