mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-17 16:44:49 -04:00
Get port and upload path from config
Signed-off-by: David Mehren <git@herrmehren.de> Co-authored-by: Yannick Bungers <git@innay.de>
This commit is contained in:
parent
99dfa2d1fb
commit
cd37eef45e
3 changed files with 21 additions and 8 deletions
17
src/main.ts
17
src/main.ts
|
@ -5,10 +5,12 @@
|
|||
*/
|
||||
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { AppModule } from './app.module';
|
||||
import { AppConfig } from './config/app.config';
|
||||
import { NestConsoleLoggerService } from './logger/nest-console-logger.service';
|
||||
|
||||
async function bootstrap() {
|
||||
|
@ -16,6 +18,8 @@ async function bootstrap() {
|
|||
const logger = await app.resolve(NestConsoleLoggerService);
|
||||
logger.log('Switching logger', 'AppBootstrap');
|
||||
app.useLogger(logger);
|
||||
const configService = app.get(ConfigService);
|
||||
const appConfig = configService.get<AppConfig>('appConfig');
|
||||
|
||||
const swaggerOptions = new DocumentBuilder()
|
||||
.setTitle('HedgeDoc')
|
||||
|
@ -31,12 +35,13 @@ async function bootstrap() {
|
|||
transform: true,
|
||||
}),
|
||||
);
|
||||
// TODO: Get uploads directory from config
|
||||
app.useStaticAssets('uploads', {
|
||||
prefix: '/uploads',
|
||||
});
|
||||
await app.listen(3000);
|
||||
logger.log('Listening on port 3000', 'AppBootstrap');
|
||||
if (appConfig.media.backend.use === 'filesystem') {
|
||||
app.useStaticAssets('uploads', {
|
||||
prefix: appConfig.media.backend.filesystem.uploadPath,
|
||||
});
|
||||
}
|
||||
await app.listen(appConfig.port);
|
||||
logger.log(`Listening on port ${appConfig.port}`, 'AppBootstrap');
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue