Skip to content

Commit

Permalink
add check for undefined middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
HomelessDinosaur committed Feb 15, 2023
1 parent a70d6bd commit 829564b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/resources/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ class Route<SecurityDefs extends string> {
this.api = api;
this.path = path;
const { middleware = [] } = opts;
this.middleware = Array.isArray(middleware) ? middleware : [middleware];
this.middleware = Array.isArray(middleware)
? middleware
: middleware
? [middleware]
: [];
}

async method(
Expand Down Expand Up @@ -258,7 +262,11 @@ class Api<SecurityDefs extends string> extends Base<ApiDetails> {
} = options;
// prepend / to path if its not there
this.path = path.replace(/^\/?/, '/');
this.middleware = Array.isArray(middleware) ? middleware : [middleware];
this.middleware = Array.isArray(middleware)
? middleware
: middleware
? [middleware]
: [];
this.securityDefinitions = securityDefinitions;
this.security = security;
this.routes = [];
Expand Down

0 comments on commit 829564b

Please sign in to comment.