From 4bf47219adc2cf298e3fe0c9a5b958177e43e424 Mon Sep 17 00:00:00 2001 From: Paulius Date: Thu, 30 May 2024 14:22:56 +0100 Subject: [PATCH] VR-99: swagger JSON is being looked at src/ rather than build/ fix. (#40) * VR-99: swagger JSON is being looked at src/ rather than build/ fix. * VR-99: rebase and version bump. * VR-99: rebase and version bump. * VR-99: versiom bump/ * VR-99: unused variable. --------- Co-authored-by: Paulius Michelevicius --- package-lock.json | 4 ++-- package.json | 2 +- src/swagger.ts | 10 +++++++--- tsconfig.json | 6 +++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4a026aab..0824cf15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "veritable-ui", - "version": "0.3.13", + "version": "0.3.14", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "veritable-ui", - "version": "0.3.13", + "version": "0.3.14", "license": "Apache-2.0", "dependencies": { "@digicatapult/tsoa-oauth-express": "^0.1.2", diff --git a/package.json b/package.json index b5ba8cc6..3237e624 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "veritable-ui", - "version": "0.3.13", + "version": "0.3.14", "description": "UI for Veritable", "main": "src/index.ts", "type": "module", diff --git a/src/swagger.ts b/src/swagger.ts index d9e158a5..4b587e97 100644 --- a/src/swagger.ts +++ b/src/swagger.ts @@ -1,8 +1,12 @@ -import fs from 'node:fs/promises' +import fs from 'fs/promises' +import path from 'path' +import { fileURLToPath } from 'url' -import path from 'node:path' import { Env } from './env.js' +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) + /** * Monkey-patch the generated swagger JSON so that when it is valid for the deployed environment * @param env Environment containing configuration for monkey-patching the swagger @@ -13,7 +17,7 @@ export default async function loadApiSpec(env: Env): Promise { const authorizationUrl = `${env.get('IDP_PUBLIC_URL_PREFIX')}${env.get('IDP_AUTH_PATH')}` const tokenUrl = `${env.get('IDP_PUBLIC_URL_PREFIX')}${env.get('IDP_TOKEN_PATH')}` - const swaggerBuffer = await fs.readFile(path.join('src/swagger.json')) + const swaggerBuffer = await fs.readFile(path.join(__dirname, './swagger.json')) const swaggerJson = JSON.parse(swaggerBuffer.toString('utf8')) swaggerJson.info.title += `:${API_SWAGGER_HEADING}` swaggerJson.components.securitySchemes.oauth2.flows.authorizationCode.authorizationUrl = authorizationUrl diff --git a/tsconfig.json b/tsconfig.json index afc65469..68ddf6c0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,9 @@ "plugins": [{ "name": "@kitajs/ts-html-plugin" }], "experimentalDecorators": true, "emitDecoratorMetadata": true, - "target": "ES2021", - "module": "NodeNext", - "moduleResolution": "NodeNext", + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "node", "forceConsistentCasingInFileNames": true, "strict": true, "sourceMap": true,