mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-01-10 10:03:11 +00:00
Config: Add rendererOrigin and maxDocumentLength to AppConfig
These are used in the /config private API call. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
f63d37dbf7
commit
c4161cec98
1 changed files with 10 additions and 0 deletions
|
@ -11,13 +11,16 @@ import { buildErrorMessage, toArrayConfig } from './utils';
|
|||
|
||||
export interface AppConfig {
|
||||
domain: string;
|
||||
rendererOrigin: string;
|
||||
port: number;
|
||||
loglevel: Loglevel;
|
||||
forbiddenNoteIds: string[];
|
||||
maxDocumentLength: number;
|
||||
}
|
||||
|
||||
const schema = Joi.object({
|
||||
domain: Joi.string().label('HD_DOMAIN'),
|
||||
rendererOrigin: Joi.string().optional().label('HD_RENDERER_ORIGIN'),
|
||||
port: Joi.number().default(3000).optional().label('PORT'),
|
||||
loglevel: Joi.string()
|
||||
.valid(...Object.values(Loglevel))
|
||||
|
@ -29,15 +32,22 @@ const schema = Joi.object({
|
|||
.optional()
|
||||
.default([])
|
||||
.label('HD_FORBIDDEN_NOTE_IDS'),
|
||||
maxDocumentLength: Joi.number()
|
||||
.default(100000)
|
||||
.optional()
|
||||
.label('HD_MAX_DOCUMENT_LENGTH'),
|
||||
});
|
||||
|
||||
export default registerAs('appConfig', () => {
|
||||
const appConfig = schema.validate(
|
||||
{
|
||||
domain: process.env.HD_DOMAIN,
|
||||
rendererOrigin: process.env.HD_RENDERER_ORIGIN,
|
||||
port: parseInt(process.env.PORT) || undefined,
|
||||
loglevel: process.env.HD_LOGLEVEL,
|
||||
forbiddenNoteIds: toArrayConfig(process.env.HD_FORBIDDEN_NOTE_IDS, ','),
|
||||
maxDocumentLength:
|
||||
parseInt(process.env.HD_MAX_DOCUMENT_LENGTH) || undefined,
|
||||
},
|
||||
{
|
||||
abortEarly: false,
|
||||
|
|
Loading…
Reference in a new issue