diff --git a/.gitignore b/.gitignore index e6c6c37be..cb39c2ff8 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,6 @@ dist public/uploads/* !public/uploads/.gitkeep +!public/.gitkeep uploads test_uploads diff --git a/public/.gitkeep b/public/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/src/frontend-config/frontend-config.dto.ts b/src/frontend-config/frontend-config.dto.ts index bb67a4c09..057dacb32 100644 --- a/src/frontend-config/frontend-config.dto.ts +++ b/src/frontend-config/frontend-config.dto.ts @@ -7,7 +7,6 @@ import { IsArray, IsBoolean, - IsDate, IsNumber, IsOptional, IsString, @@ -78,22 +77,6 @@ export class AuthProviders { internal: boolean; } -export class BannerDto { - /** - * The text that is shown in the banner - * @example This is a test banner - */ - @IsString() - text: string; - - /** - * When the banner was last changed - * @example "2020-12-01 12:23:34" - */ - @IsDate() - updateTime: Date; -} - export class BrandingDto { /** * The name to be displayed next to the HedgeDoc logo @@ -227,12 +210,6 @@ export class FrontendConfigDto { @ValidateNested() branding: BrandingDto; - /** - * An optional banner that will be shown - */ - @ValidateNested() - banner: BannerDto; - /** * The custom names of auth providers, which can be specified multiple times */ diff --git a/src/frontend-config/frontend-config.service.spec.ts b/src/frontend-config/frontend-config.service.spec.ts index d2e90a7e0..83bc38b9f 100644 --- a/src/frontend-config/frontend-config.service.spec.ts +++ b/src/frontend-config/frontend-config.service.spec.ts @@ -276,10 +276,6 @@ describe('FrontendConfigService', () => { authConfig.oauth2.length !== 0, ); expect(config.allowAnonymous).toEqual(false); - expect(config.banner.text).toEqual(''); - expect(config.banner.updateTime).toEqual( - new Date(0), - ); expect(config.branding.name).toEqual(customName); expect(config.branding.logo).toEqual( customLogo ? new URL(customLogo) : undefined, diff --git a/src/frontend-config/frontend-config.service.ts b/src/frontend-config/frontend-config.service.ts index 6bb39e4b1..1236ce1ff 100644 --- a/src/frontend-config/frontend-config.service.ts +++ b/src/frontend-config/frontend-config.service.ts @@ -8,7 +8,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { ConsoleLoggerService } from '../logger/console-logger.service'; import { AuthProviders, - BannerDto, BrandingDto, CustomAuthNamesDto, FrontendConfigDto, @@ -24,8 +23,6 @@ import externalServicesConfiguration, { ExternalServicesConfig, } from '../config/external-services.config'; import { getServerVersionFromPackageJson } from '../utils/serverVersion'; -import { promises as fs, Stats } from 'fs'; -import { join } from 'path'; @Injectable() export class FrontendConfigService { @@ -49,7 +46,6 @@ export class FrontendConfigService { allowAnonymous: false, allowRegister: this.authConfig.email.enableRegister, authProviders: this.getAuthProviders(), - banner: await FrontendConfigService.getBanner(), branding: this.getBranding(), customAuthNames: this.getCustomAuthNames(), iframeCommunication: this.getIframeCommunication(), @@ -138,23 +134,4 @@ export class FrontendConfigService { : new URL(this.appConfig.domain), }; } - - private static async getBanner(): Promise { - const path = join(__dirname, '../../banner.md'); - try { - const bannerContent: string = await fs.readFile(path, { - encoding: 'utf8', - }); - const fileStats: Stats = await fs.stat(path); - return { - text: bannerContent, - updateTime: fileStats.mtime, - }; - } catch (e) { - return { - text: '', - updateTime: new Date(0), - }; - } - } } diff --git a/src/main.ts b/src/main.ts index 7b5cf6e3f..212922f91 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,6 +55,13 @@ async function bootstrap(): Promise { prefix: '/uploads/', }); } + logger.log( + `Serving the local folder 'public' under '/public'`, + 'AppBootstrap', + ); + app.useStaticAssets('public', { + prefix: '/public/', + }); await app.listen(appConfig.port); logger.log(`Listening on port ${appConfig.port}`, 'AppBootstrap'); }