From 76c42c40946baf45f953cd30b23b946e22dca326 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 29 Jun 2021 08:20:17 +0100 Subject: [PATCH] Enable hot reloading of server typescript and fix error when updating app and nmot providing a name --- packages/server/nodemon.json | 6 ++++++ packages/server/package.json | 2 +- packages/server/src/api/controllers/application.js | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 packages/server/nodemon.json diff --git a/packages/server/nodemon.json b/packages/server/nodemon.json new file mode 100644 index 0000000000..a5640776e4 --- /dev/null +++ b/packages/server/nodemon.json @@ -0,0 +1,6 @@ +{ + "watch": ["src"], + "ext": "js,ts,json", + "ignore": ["src/**/*.spec.ts", "src/**/*.spec.js"], + "exec": "ts-node src/index.ts" +} \ No newline at end of file diff --git a/packages/server/package.json b/packages/server/package.json index c86ce158da..776f03d839 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -18,7 +18,7 @@ "dev:stack:up": "node scripts/dev/manage.js up", "dev:stack:down": "node scripts/dev/manage.js down", "dev:stack:nuke": "node scripts/dev/manage.js nuke", - "dev:builder": "yarn run dev:stack:up && ts-node src/index.ts", + "dev:builder": "yarn run dev:stack:up && nodemon", "format": "prettier --config ../../.prettierrc.json 'src/**/*.ts' --write", "lint": "eslint --fix src/", "lint:fix": "yarn run format && yarn run lint", diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index 7db8bacd0b..24cd1cd3c7 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -67,15 +67,18 @@ async function getAppUrlIfNotInUse(ctx) { let url if (ctx.request.body.url) { url = encodeURI(ctx.request.body.url) - } else { + } else if (ctx.request.body.name) { url = encodeURI(`${ctx.request.body.name}`) } - url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase() + if (url) { + url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase() + } if (!env.SELF_HOSTED) { return url } const deployedApps = await getDeployedApps(ctx) if ( + url && deployedApps[url] != null && deployedApps[url].appId !== ctx.params.appId ) {