Skip to content

Commit 66cd0f7

Browse files
committed
pre compute plan fallback
1 parent af01a9f commit 66cd0f7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/middleware/common.middleware.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import config from '../../config/index.js'
1818
import { readFileSync } from 'node:fs'
1919

2020
const planFallback = JSON.parse(readFileSync(new URL('../../config/plan-fallback.json', import.meta.url), 'utf8'))
21+
const PLAN_FALLBACK_DATASETS_JSON = JSON.stringify(planFallback.datasets)
2122
/**
2223
* Middleware. Set `req.handlerName` to a string that will identify
2324
* the function that threw the error.
@@ -398,7 +399,7 @@ export const checkSpecificationFallback = (req, res, next) => {
398399
if (specification && specification.specification === 'local-plan') {
399400
const fallbackDataset = planFallback.datasets.find(d => d.dataset === req.dataset.dataset)
400401
if (fallbackDataset) {
401-
req.specification = { json: JSON.stringify(planFallback.datasets) }
402+
req.specification = { json: PLAN_FALLBACK_DATASETS_JSON }
402403
}
403404
}
404405

0 commit comments

Comments
 (0)