From b70e29433e45934975e41ffdc32e288988aba9b0 Mon Sep 17 00:00:00 2001 From: Mutasem Date: Tue, 3 May 2022 13:00:11 +0200 Subject: [PATCH] disable api differently --- packages/cli/src/PublicApi/index.ts | 21 +++++++++---------- packages/cli/src/Server.ts | 4 ++-- packages/cli/test/integration/shared/utils.ts | 4 ++-- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/PublicApi/index.ts b/packages/cli/src/PublicApi/index.ts index 93dc465699..1ea0225a8f 100644 --- a/packages/cli/src/PublicApi/index.ts +++ b/packages/cli/src/PublicApi/index.ts @@ -58,15 +58,14 @@ function createApiRouter( } export const loadPublicApiVersions = async (): Promise => { - // const swaggerThemePath = path.join(__dirname, 'swaggerTheme.css'); - // const folders = await fs.readdir(__dirname); - // const css = (await fs.readFile(swaggerThemePath)).toString(); - // const versions = folders.filter((folderName) => folderName.startsWith('v')); - // const apiRouters: express.Router[] = []; - // for (const version of versions) { - // const openApiPath = path.join(__dirname, version, 'openapi.yml'); - // apiRouters.push(createApiRouter(version, openApiPath, __dirname, css)); - // } - // return apiRouters; - return []; + const swaggerThemePath = path.join(__dirname, 'swaggerTheme.css'); + const folders = await fs.readdir(__dirname); + const css = (await fs.readFile(swaggerThemePath)).toString(); + const versions = folders.filter((folderName) => folderName.startsWith('v')); + const apiRouters: express.Router[] = []; + for (const version of versions) { + const openApiPath = path.join(__dirname, version, 'openapi.yml'); + apiRouters.push(createApiRouter(version, openApiPath, __dirname, css)); + } + return apiRouters; }; diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 1a723d3e87..ea91036c6c 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -164,7 +164,7 @@ import { isEmailSetUp, isUserManagementEnabled, } from './UserManagement/UserManagementHelper'; -import { loadPublicApiVersions } from './PublicApi'; +// import { loadPublicApiVersions } from './PublicApi'; require('body-parser-xml')(bodyParser); @@ -577,7 +577,7 @@ class App { }); if (!config.getEnv('publicApi.disabled')) { - this.app.use(`/${this.publicApiEndpoint}`, ...(await loadPublicApiVersions())); + // this.app.use(`/${this.publicApiEndpoint}`, ...(await loadPublicApiVersions())); } // Parse cookies for easier access this.app.use(cookieParser()); diff --git a/packages/cli/test/integration/shared/utils.ts b/packages/cli/test/integration/shared/utils.ts index 77d317e218..381b59b682 100644 --- a/packages/cli/test/integration/shared/utils.ts +++ b/packages/cli/test/integration/shared/utils.ts @@ -23,7 +23,7 @@ import { passwordResetNamespace as passwordResetEndpoints } from '../../../src/U import { issueJWT } from '../../../src/UserManagement/auth/jwt'; import { getLogger } from '../../../src/Logger'; import { credentialsController } from '../../../src/api/credentials.api'; -import { loadPublicApiVersions } from '../../../src/PublicApi/'; +// import { loadPublicApiVersions } from '../../../src/PublicApi/'; import type { User } from '../../../src/databases/entities/User'; import { Telemetry } from '../../../src/telemetry'; import type { ApiPath, EndpointGroup, SmtpTestAccount } from './types'; @@ -66,7 +66,7 @@ export async function initTestServer({ if (routerEndpoints.length) { const map: Record = { credentials: credentialsController, - publicApi: await loadPublicApiVersions(), + // publicApi: await loadPublicApiVersions(), }; for (const group of routerEndpoints) {