Skip to content

Commit

Permalink
fix: "urlencodedParser is not iterable" error
Browse files Browse the repository at this point in the history
The express loader pulls middleware out of the stack to reorder it, but
it wasn't correctly handling them when they were missing. If the
middleware type was not found the variable was left undefined and
resulted in an error when trying to use the spread syntax on it later.
Initialize each of these to an empty array so we have a no-op fallback
if any of the middleware are not found.
  • Loading branch information
Jonathan Mast authored and dziraf committed Mar 4, 2022
1 parent f31f68c commit 914129a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/loaders/express.loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export class ExpressLoader extends AbstractLoader {
}

private reorderRoutes(app) {
let jsonParser;
let urlencodedParser;
let admin;
let jsonParser = [];
let urlencodedParser = [];
let admin = [];

// Nestjs uses bodyParser under the hood which is in conflict with adminjs setup.
// Due to adminjs-expressjs usage of formidable we have to move body parser in layer tree after adminjs init.
Expand Down

0 comments on commit 914129a

Please sign in to comment.