mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 02:35:23 -04:00
fix(repository): Move backend code into subdirectory
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
86584e705f
commit
bf30cbcf48
272 changed files with 87 additions and 67 deletions
80
backend/src/config/customization.config.ts
Normal file
80
backend/src/config/customization.config.ts
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { registerAs } from '@nestjs/config';
|
||||
import * as Joi from 'joi';
|
||||
|
||||
import { buildErrorMessage } from './utils';
|
||||
|
||||
export interface CustomizationConfig {
|
||||
branding: {
|
||||
customName: string;
|
||||
customLogo: string;
|
||||
};
|
||||
specialUrls: {
|
||||
privacy: string;
|
||||
termsOfUse: string;
|
||||
imprint: string;
|
||||
};
|
||||
}
|
||||
|
||||
const schema = Joi.object({
|
||||
branding: Joi.object({
|
||||
customName: Joi.string().optional().label('HD_CUSTOM_NAME'),
|
||||
customLogo: Joi.string()
|
||||
.uri({
|
||||
scheme: [/https?/],
|
||||
})
|
||||
.optional()
|
||||
.label('HD_CUSTOM_LOGO'),
|
||||
}),
|
||||
specialUrls: Joi.object({
|
||||
privacy: Joi.string()
|
||||
.uri({
|
||||
scheme: /https?/,
|
||||
})
|
||||
.optional()
|
||||
.label('HD_PRIVACY_URL'),
|
||||
termsOfUse: Joi.string()
|
||||
.uri({
|
||||
scheme: /https?/,
|
||||
})
|
||||
.optional()
|
||||
.label('HD_TERMS_OF_USE_URL'),
|
||||
imprint: Joi.string()
|
||||
.uri({
|
||||
scheme: /https?/,
|
||||
})
|
||||
.optional()
|
||||
.label('HD_IMPRINT_URL'),
|
||||
}),
|
||||
});
|
||||
|
||||
export default registerAs('customizationConfig', () => {
|
||||
const customizationConfig = schema.validate(
|
||||
{
|
||||
branding: {
|
||||
customName: process.env.HD_CUSTOM_NAME,
|
||||
customLogo: process.env.HD_CUSTOM_LOGO,
|
||||
},
|
||||
specialUrls: {
|
||||
privacy: process.env.HD_PRIVACY_URL,
|
||||
termsOfUse: process.env.HD_TERMS_OF_USE_URL,
|
||||
imprint: process.env.HD_IMPRINT_URL,
|
||||
},
|
||||
},
|
||||
{
|
||||
abortEarly: false,
|
||||
presence: 'required',
|
||||
},
|
||||
);
|
||||
if (customizationConfig.error) {
|
||||
const errorMessages = customizationConfig.error.details.map(
|
||||
(detail) => detail.message,
|
||||
);
|
||||
throw new Error(buildErrorMessage(errorMessages));
|
||||
}
|
||||
return customizationConfig.value as CustomizationConfig;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue