allow method specific middleware

This commit is contained in:
Erik 2022-11-09 16:16:44 +02:00
parent 1bb2421e9d
commit df2d7a7ed5
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -28,9 +28,9 @@ class Endpoint {
init () {
for (const [ method, cb ] of this.methods) {
for (const [ method, cb, mw = [] ] of this.methods) {
if (typeof method !== 'string') throw new Error(`Invalid method parameter type in Endpoint ${this.name} major path`);
this.client.app[method](this.path, ...this.middleware, cb);
this.client.app[method](this.path, ...this.middleware, ...mw, cb);
}
this.subpaths = [ ...this._subpaths, ...this.subpaths ];