From 21348ebf26914c15bf57e176825ff73e4c216ddd Mon Sep 17 00:00:00 2001 From: Nicolas Dupont Date: Tue, 3 Dec 2024 15:42:16 +0100 Subject: [PATCH] Remove magic strings --- src/collection-api/routes/metadata.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/collection-api/routes/metadata.js b/src/collection-api/routes/metadata.js index 27c28221..0a1ca1fa 100644 --- a/src/collection-api/routes/metadata.js +++ b/src/collection-api/routes/metadata.js @@ -6,6 +6,9 @@ import yaml from 'js-yaml'; import Service from '../../archivist/services/service.js'; +const METADATA_FILENAME = 'metadata.yml'; +const PACKAGE_JSON_PATH = '../../../package.json'; + /** * @swagger * tags: @@ -130,8 +133,8 @@ import Service from '../../archivist/services/service.js'; export default async function metadataRouter(collectionPath, services) { const router = express.Router(); - const STATIC_METADATA = yaml.load(await fs.readFile(path.join(collectionPath, '/metadata.yml'), 'utf8')); - const { version: engineVersion } = JSON.parse(await fs.readFile(new URL('../../../package.json', import.meta.url))); + const STATIC_METADATA = yaml.load(await fs.readFile(path.join(collectionPath, METADATA_FILENAME), 'utf8')); + const { version: engineVersion } = JSON.parse(await fs.readFile(new URL(PACKAGE_JSON_PATH, import.meta.url))); /** * @swagger