From 19e5be19bf453ee9f8462d35b9a6d8962ccac18c Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 6 Apr 2020 09:09:48 +0100 Subject: [PATCH] config in context --- packages/server/middleware/routes/apps.js | 2 +- packages/server/middleware/routes/builderRouter.js | 1 + packages/server/middleware/routes/components.js | 6 +++--- packages/server/middleware/routes/pages.js | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/server/middleware/routes/apps.js b/packages/server/middleware/routes/apps.js index 45ddceb96d..941be4eabc 100644 --- a/packages/server/middleware/routes/apps.js +++ b/packages/server/middleware/routes/apps.js @@ -23,7 +23,7 @@ router.get("/_builder/api/:appname/appPackage", async ctx => { router .post("/_builder/api/:appname/backend", async ctx => { await saveBackend( - config, + ctx.config, ctx.params.appname, ctx.request.body.appDefinition, ctx.request.body.accessLevels diff --git a/packages/server/middleware/routes/builderRouter.js b/packages/server/middleware/routes/builderRouter.js index e47e45ed09..0071db0a14 100644 --- a/packages/server/middleware/routes/builderRouter.js +++ b/packages/server/middleware/routes/builderRouter.js @@ -22,6 +22,7 @@ module.exports = (config, app) => { .use(async (ctx, next) => { ctx.sessionId = ctx.session._sessCtx.externalKey ctx.session.accessed = true + ctx.config = config const pathParts = ctx.path.split("/") diff --git a/packages/server/middleware/routes/components.js b/packages/server/middleware/routes/components.js index e89fec6b3b..8c770d57be 100644 --- a/packages/server/middleware/routes/components.js +++ b/packages/server/middleware/routes/components.js @@ -11,7 +11,7 @@ const router = Router(); router.get("/_builder/api/:appname/components", async ctx => { try { ctx.body = getComponentDefinitions( - config, + ctx.config, ctx.params.appname, ctx.query.lib ) @@ -27,7 +27,7 @@ router.get("/_builder/api/:appname/components", async ctx => { router.get("/_builder/api/:appname/componentlibrary", async ctx => { const info = await componentLibraryInfo( - config, + ctx.config, ctx.params.appname, ctx.query.lib ? decodeURI(ctx.query.lib) : "" ) @@ -37,7 +37,7 @@ router.get("/_builder/api/:appname/componentlibrary", async ctx => { router.get("/_builder/:appname/componentlibrary", async ctx => { const info = await componentLibraryInfo( - config, + ctx.config, ctx.params.appname, ctx.query.lib ) diff --git a/packages/server/middleware/routes/pages.js b/packages/server/middleware/routes/pages.js index ee954b36ff..08a9418c9d 100644 --- a/packages/server/middleware/routes/pages.js +++ b/packages/server/middleware/routes/pages.js @@ -59,7 +59,7 @@ router router.post("/_builder/api/:appname/pages/:pageName", async ctx => { await buildPage( - config, + ctx.config, ctx.params.appname, ctx.params.pageName, ctx.request.body