mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-30 14:55:27 -04:00
config: splits config in multiple files
splits the big appConfig in multiple configs adds media.config.mock.ts Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
d59ccaba54
commit
072ef223e0
18 changed files with 287 additions and 174 deletions
37
src/config/csp.config.ts
Normal file
37
src/config/csp.config.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import * as Joi from 'joi';
|
||||
import { registerAs } from '@nestjs/config';
|
||||
|
||||
export interface CspConfig {
|
||||
enable: boolean;
|
||||
maxAgeSeconds: number;
|
||||
includeSubdomains: boolean;
|
||||
preload: boolean;
|
||||
}
|
||||
|
||||
const cspSchema = Joi.object({
|
||||
enable: Joi.boolean().default(true).optional(),
|
||||
reportURI: Joi.string().optional(),
|
||||
});
|
||||
|
||||
export default registerAs('cspConfig', async () => {
|
||||
const cspConfig = cspSchema.validate(
|
||||
{
|
||||
enable: process.env.HD_CSP_ENABLE || true,
|
||||
reportURI: process.env.HD_CSP_REPORTURI,
|
||||
},
|
||||
{
|
||||
abortEarly: false,
|
||||
presence: 'required',
|
||||
},
|
||||
);
|
||||
if (cspConfig.error) {
|
||||
throw new Error(cspConfig.error.toString());
|
||||
}
|
||||
return cspConfig.value;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue