From 97da370301fd8e6d9fdd8062ecbda61857ce6244 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Sun, 12 Mar 2023 09:59:27 +0000 Subject: [PATCH] feat: provide clear message when app is not found --- packages/backend/src/helpers/get-app.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/helpers/get-app.ts b/packages/backend/src/helpers/get-app.ts index 52f73894..436965d4 100644 --- a/packages/backend/src/helpers/get-app.ts +++ b/packages/backend/src/helpers/get-app.ts @@ -22,7 +22,11 @@ const apps = fs return apps; }, {} as TApps); -async function getDefaultExport(appKey: string) { +async function getAppDefaultExport(appKey: string) { + if (!Object.prototype.hasOwnProperty.call(apps, appKey)) { + throw new Error(`An application with the "${appKey}" key couldn't be found.`); + } + return (await apps[appKey]).default; } @@ -31,7 +35,7 @@ function stripFunctions(data: C): C { } const getApp = async (appKey: string, stripFuncs = true) => { - let appData: IApp = cloneDeep(await getDefaultExport(appKey)); + let appData: IApp = cloneDeep(await getAppDefaultExport(appKey)); if (appData.auth) { appData = addAuthenticationSteps(appData);