Skip to content

Commit

Permalink
fix enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechGrancow committed Nov 30, 2023
1 parent e482fd6 commit 1d41b33
Showing 1 changed file with 26 additions and 32 deletions.
58 changes: 26 additions & 32 deletions apps/server/src/apps/admin-api-server.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,32 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib';
async function bootstrap() {
sourceMapInstall();

const enabled = Configuration.get('ADMIN_API__ENABLED') as boolean;

if (enabled) {
const nestAdminServerExpress = express();
const nestAdminServerExpressAdapter = new ExpressAdapter(nestAdminServerExpress);
nestAdminServerExpressAdapter.disable('x-powered-by');

const nestAdminServerApp = await NestFactory.create(AdminApiServerModule, nestAdminServerExpressAdapter);
const logger = await nestAdminServerApp.resolve(Logger);
const legacyLogger = await nestAdminServerApp.resolve(LegacyLogger);
nestAdminServerApp.useLogger(legacyLogger);
nestAdminServerApp.enableCors();

enableOpenApiDocs(nestAdminServerApp, 'docs');
nestAdminServerApp.setGlobalPrefix('/admin/api/v1');

await nestAdminServerApp.init();

const adminApiServerPort = Configuration.get('ADMIN_API__PORT') as number;

nestAdminServerExpress.listen(adminApiServerPort, () => {
logger.info(
new AppStartLoggable({
appName: 'Admin API server app',
port: adminApiServerPort,
mountsDescription: `/admin/api/v1 --> Admin API Server`,
})
);
});
} else {
process.exit(0);
}
const nestAdminServerExpress = express();
const nestAdminServerExpressAdapter = new ExpressAdapter(nestAdminServerExpress);
nestAdminServerExpressAdapter.disable('x-powered-by');

const nestAdminServerApp = await NestFactory.create(AdminApiServerModule, nestAdminServerExpressAdapter);
const logger = await nestAdminServerApp.resolve(Logger);
const legacyLogger = await nestAdminServerApp.resolve(LegacyLogger);
nestAdminServerApp.useLogger(legacyLogger);
nestAdminServerApp.enableCors();

enableOpenApiDocs(nestAdminServerApp, 'docs');
nestAdminServerApp.setGlobalPrefix('/admin/api/v1');

await nestAdminServerApp.init();

const adminApiServerPort = Configuration.get('ADMIN_API__PORT') as number;

nestAdminServerExpress.listen(adminApiServerPort, () => {
logger.info(
new AppStartLoggable({
appName: 'Admin API server app',
port: adminApiServerPort,
mountsDescription: `/admin/api/v1 --> Admin API Server`,
})
);
});
}

void bootstrap();

0 comments on commit 1d41b33

Please sign in to comment.