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:
Philip Molares 2021-03-01 21:00:55 +01:00
parent f63d37dbf7
commit c4161cec98

View file

@ -11,13 +11,16 @@ import { buildErrorMessage, toArrayConfig } from './utils';
export interface AppConfig { export interface AppConfig {
domain: string; domain: string;
rendererOrigin: string;
port: number; port: number;
loglevel: Loglevel; loglevel: Loglevel;
forbiddenNoteIds: string[]; forbiddenNoteIds: string[];
maxDocumentLength: number;
} }
const schema = Joi.object({ const schema = Joi.object({
domain: Joi.string().label('HD_DOMAIN'), domain: Joi.string().label('HD_DOMAIN'),
rendererOrigin: Joi.string().optional().label('HD_RENDERER_ORIGIN'),
port: Joi.number().default(3000).optional().label('PORT'), port: Joi.number().default(3000).optional().label('PORT'),
loglevel: Joi.string() loglevel: Joi.string()
.valid(...Object.values(Loglevel)) .valid(...Object.values(Loglevel))
@ -29,15 +32,22 @@ const schema = Joi.object({
.optional() .optional()
.default([]) .default([])
.label('HD_FORBIDDEN_NOTE_IDS'), .label('HD_FORBIDDEN_NOTE_IDS'),
maxDocumentLength: Joi.number()
.default(100000)
.optional()
.label('HD_MAX_DOCUMENT_LENGTH'),
}); });
export default registerAs('appConfig', () => { export default registerAs('appConfig', () => {
const appConfig = schema.validate( const appConfig = schema.validate(
{ {
domain: process.env.HD_DOMAIN, domain: process.env.HD_DOMAIN,
rendererOrigin: process.env.HD_RENDERER_ORIGIN,
port: parseInt(process.env.PORT) || undefined, port: parseInt(process.env.PORT) || undefined,
loglevel: process.env.HD_LOGLEVEL, loglevel: process.env.HD_LOGLEVEL,
forbiddenNoteIds: toArrayConfig(process.env.HD_FORBIDDEN_NOTE_IDS, ','), forbiddenNoteIds: toArrayConfig(process.env.HD_FORBIDDEN_NOTE_IDS, ','),
maxDocumentLength:
parseInt(process.env.HD_MAX_DOCUMENT_LENGTH) || undefined,
}, },
{ {
abortEarly: false, abortEarly: false,