From 830f3bbd4d38c8a2e160cafb50f13eab5b5a2071 Mon Sep 17 00:00:00 2001 From: SanderElias Date: Tue, 21 Jan 2020 13:16:49 +0100 Subject: [PATCH 1/2] fix(behaviour of postrender array): makes sure the postreder array is passed correctly => { const routesToGenerate = await routeList.reduce(async (result: Promise, cur: string) => { const x = await result; - if (scullyConfig.routes[cur]) { - const postRenderers: string[] = Array.isArray(scullyConfig.routes[cur].postRenderers) - ? scullyConfig.routes[cur].postRenderers - : []; + const config = scullyConfig.routes[cur]; + if (config) { + const postRenderers: string[] = Array.isArray(config.postRenderers) ? config.postRenderers : undefined; /** adding in the postrenderes. Note that the plugin might choose to overwrite the ones that come from the config */ - const r = (await routePluginHandler(cur)).map(r => ({ postRenderers, ...r})); + const r = (await routePluginHandler(cur)).map(row => + postRenderers ? {postRenderers, ...row, config} : {...row, config} + ); x.push(...r); } else if (cur.includes('/:')) { logWarn(`No configuration for route "${yellow(cur)}" found. Skipping`); @@ -27,6 +28,7 @@ export const addOptionalRoutes = async (routeList = [] as string[]): Promise Date: Tue, 21 Jan 2020 13:37:36 +0100 Subject: [PATCH 2/2] feat(index.ts): export httpGetJson helper from scully --- scully/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scully/index.ts b/scully/index.ts index 06eeda287..5f789633e 100644 --- a/scully/index.ts +++ b/scully/index.ts @@ -1,10 +1,11 @@ -import {registerPlugin, configValidator} from './pluginManagement/pluginRepository'; +import {configValidator, registerPlugin} from './pluginManagement/pluginRepository'; import './pluginManagement/systemPlugins'; import {HandledRoute} from './routerPlugins/addOptionalRoutesPlugin'; import {updateScullyConfig} from './utils/config'; +import {httpGetJson} from './utils/httpGetJson'; import {RouteTypes, ScullyConfig} from './utils/interfacesandenums'; -import {routeSplit} from './utils/routeSplit'; import {replaceFirstRouteParamWithVal} from './utils/replaceFirstRouteParamWithVal'; +import {routeSplit} from './utils/routeSplit'; import {startScully} from './utils/startup'; export { @@ -17,4 +18,5 @@ export { routeSplit, replaceFirstRouteParamWithVal, configValidator, + httpGetJson, };