@trojs/openapi-server 1.9.1 → 1.10.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/package.json +1 -1
- package/src/api.js +5 -2
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -30,6 +30,7 @@ import { setupRouter } from './router.js'
|
|
|
30
30
|
* @property {boolean=} apiDocs
|
|
31
31
|
* @property {AjvOpts=} ajvOptions
|
|
32
32
|
* @property {AjvCustomizer=} customizeAjv
|
|
33
|
+
* @property {any[]=} middleware
|
|
33
34
|
*/
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -58,7 +59,8 @@ export class Api {
|
|
|
58
59
|
swagger,
|
|
59
60
|
apiDocs,
|
|
60
61
|
ajvOptions,
|
|
61
|
-
customizeAjv
|
|
62
|
+
customizeAjv,
|
|
63
|
+
middleware = []
|
|
62
64
|
}) {
|
|
63
65
|
this.version = version
|
|
64
66
|
this.specification = specification
|
|
@@ -75,6 +77,7 @@ export class Api {
|
|
|
75
77
|
this.apiDocs = apiDocs ?? true
|
|
76
78
|
this.ajvOptions = ajvOptions ?? { allErrors: false }
|
|
77
79
|
this.customizeAjv = customizeAjv
|
|
80
|
+
this.middleware = middleware
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
setup () {
|
|
@@ -108,7 +111,7 @@ export class Api {
|
|
|
108
111
|
customizeAjv: this.customizeAjv
|
|
109
112
|
})
|
|
110
113
|
api.init()
|
|
111
|
-
|
|
114
|
+
this.middleware.forEach((fn) => router.use(fn))
|
|
112
115
|
router.use((request, response) =>
|
|
113
116
|
api.handleRequest(request, request, response)
|
|
114
117
|
)
|