fix: Allow use of validations middleware in plugins

This commit is contained in:
Tom Moor
2023-09-03 16:52:46 -04:00
parent 1048ea8771
commit 3721ea2333
3 changed files with 59 additions and 30 deletions

View File

@@ -60,8 +60,11 @@ glob
.forEach((filePath: string) => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg: Router = require(path.join(process.cwd(), filePath)).default;
router.use("/", pkg.routes());
Logger.debug("lifecycle", `Registered API routes for ${filePath}`);
if (pkg && "routes" in pkg) {
router.use("/", pkg.routes());
Logger.debug("lifecycle", `Registered API routes for ${filePath}`);
}
});
// routes