disable api differently

This commit is contained in:
Mutasem 2022-05-03 13:00:11 +02:00
parent 886e5164fb
commit b70e29433e
3 changed files with 14 additions and 15 deletions

View file

@ -58,15 +58,14 @@ function createApiRouter(
}
export const loadPublicApiVersions = async (): Promise<express.Router[]> => {
// 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;
};

View file

@ -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());

View file

@ -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<string, express.Router | express.Router[]> = {
credentials: credentialsController,
publicApi: await loadPublicApiVersions(),
// publicApi: await loadPublicApiVersions(),
};
for (const group of routerEndpoints) {