Skip to content

Commit

Permalink
BC-7960 - Move config api to tldraw server (#5293)
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenWaysDP authored Oct 22, 2024
1 parent 30c64c9 commit d567a04
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ data:
IDENTITY_MANAGEMENT__EXTERNAL_URI: "{{ IDENTITY_MANAGEMENT__EXTERNAL_URI }}"
IDENTITY_MANAGEMENT__TENANT: "{{ IDENTITY_MANAGEMENT__TENANT }}"
IDENTITY_MANAGEMENT__CLIENTID: "{{ IDENTITY_MANAGEMENT__CLIENTID }}"
TLDRAW__WEBSOCKET_URL: "wss://{{ DOMAIN }}/tldraw-server"
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ data:
SC_THEME: "{{ SC_THEME }}"
SC_SHORTNAME: "{{ SC_SHORTNAME }}"
SC_DOMAIN: "{{ DOMAIN }}"
TLDRAW__WEBSOCKET_URL: "wss://{{ DOMAIN }}/tldraw-server"
SHLVL: "1"
# Prints slow requests above 4 s in log
# LEAD_TIME: "4000"
Expand Down
8 changes: 6 additions & 2 deletions apps/server/src/modules/server/api/dto/config.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ export class ConfigResponse {
@ApiProperty()
FEATURE_TLDRAW_ENABLED: boolean;

@ApiProperty()
TLDRAW__WEBSOCKET_URL: string;

@ApiProperty()
TLDRAW__ASSETS_ENABLED: boolean;

@ApiProperty()
TLDRAW__ASSETS_MAX_SIZE: number;
TLDRAW__ASSETS_MAX_SIZE_BYTES: number;

@ApiProperty()
TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST: string[];
Expand Down Expand Up @@ -292,7 +295,8 @@ export class ConfigResponse {
this.MIGRATION_WIZARD_DOCUMENTATION_LINK = config.MIGRATION_WIZARD_DOCUMENTATION_LINK;
this.FEATURE_TLDRAW_ENABLED = config.FEATURE_TLDRAW_ENABLED;
this.TLDRAW__ASSETS_ENABLED = config.TLDRAW__ASSETS_ENABLED;
this.TLDRAW__ASSETS_MAX_SIZE = config.TLDRAW__ASSETS_MAX_SIZE;
this.TLDRAW__WEBSOCKET_URL = config.TLDRAW__WEBSOCKET_URL;
this.TLDRAW__ASSETS_MAX_SIZE_BYTES = config.TLDRAW__ASSETS_MAX_SIZE_BYTES;
this.TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST = config.TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST;
this.FEATURE_VIDEOCONFERENCE_ENABLED = config.FEATURE_VIDEOCONFERENCE_ENABLED;
this.FEATURE_SCHULCONNEX_COURSE_SYNC_ENABLED = config.FEATURE_SCHULCONNEX_COURSE_SYNC_ENABLED;
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/modules/server/api/test/server.api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ describe('Server Controller (API)', () => {
'TEACHER_STUDENT_VISIBILITY__IS_ENABLED_BY_DEFAULT',
'TEACHER_STUDENT_VISIBILITY__IS_VISIBLE',
'TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST',
'TLDRAW__WEBSOCKET_URL',
'TLDRAW__ASSETS_ENABLED',
'TLDRAW__ASSETS_MAX_SIZE',
'TLDRAW__ASSETS_MAX_SIZE_BYTES',
'FEATURE_SCHULCONNEX_COURSE_SYNC_ENABLED',
'FEATURE_MEDIA_SHELF_ENABLED',
'BOARD_COLLABORATION_URI',
Expand Down
6 changes: 4 additions & 2 deletions apps/server/src/modules/server/server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ export interface ServerConfig
MIGRATION_WIZARD_DOCUMENTATION_LINK?: string;
FEATURE_OTHER_GROUPUSERS_PROVISIONING_ENABLED: boolean;
FEATURE_TLDRAW_ENABLED: boolean;
TLDRAW__WEBSOCKET_URL: string;
TLDRAW__ASSETS_ENABLED: boolean;
TLDRAW__ASSETS_MAX_SIZE: number;
TLDRAW__ASSETS_MAX_SIZE_BYTES: number;
TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST: string[];
I18N__AVAILABLE_LANGUAGES: LanguageType[];
I18N__DEFAULT_LANGUAGE: LanguageType;
Expand Down Expand Up @@ -230,8 +231,9 @@ const config: ServerConfig = {
BLOCKLIST_OF_EMAIL_DOMAINS: (Configuration.get('BLOCKLIST_OF_EMAIL_DOMAINS') as string)
.split(',')
.map((domain) => domain.trim()),
TLDRAW__WEBSOCKET_URL: Configuration.get('TLDRAW__WEBSOCKET_URL') as string,
TLDRAW__ASSETS_ENABLED: Configuration.get('TLDRAW__ASSETS_ENABLED') as boolean,
TLDRAW__ASSETS_MAX_SIZE: Configuration.get('TLDRAW__ASSETS_MAX_SIZE') as number,
TLDRAW__ASSETS_MAX_SIZE_BYTES: Configuration.get('TLDRAW__ASSETS_MAX_SIZE_BYTES') as number,
TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST: (Configuration.get('TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST') as string).split(
','
),
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/tldraw/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface TldrawConfig {
REDIS_URI: string;
TLDRAW_ASSETS_ENABLED: boolean;
TLDRAW_ASSETS_SYNC_ENABLED: boolean;
TLDRAW_ASSETS_MAX_SIZE: number;
TLDRAW_ASSETS_MAX_SIZE_BYTES: number;
ASSETS_ALLOWED_MIME_TYPES_LIST: string;
API_HOST: number;
TLDRAW_MAX_DOCUMENT_SIZE: number;
Expand Down Expand Up @@ -50,7 +50,7 @@ const tldrawConfig = {
REDIS_URI: Configuration.has('REDIS_URI') ? (Configuration.get('REDIS_URI') as string) : null,
TLDRAW_ASSETS_ENABLED: Configuration.get('TLDRAW__ASSETS_ENABLED') as boolean,
TLDRAW_ASSETS_SYNC_ENABLED: Configuration.get('TLDRAW__ASSETS_SYNC_ENABLED') as boolean,
TLDRAW_ASSETS_MAX_SIZE: Configuration.get('TLDRAW__ASSETS_MAX_SIZE') as number,
TLDRAW_ASSETS_MAX_SIZE_BYTES: Configuration.get('TLDRAW__ASSETS_MAX_SIZE_BYTES') as number,
ASSETS_ALLOWED_MIME_TYPES_LIST: Configuration.get('TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST') as string,
API_HOST: Configuration.get('API_HOST') as string,
TLDRAW_MAX_DOCUMENT_SIZE: Configuration.get('TLDRAW__MAX_DOCUMENT_SIZE') as number,
Expand Down
32 changes: 18 additions & 14 deletions config/default.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1525,53 +1525,69 @@
"PING_TIMEOUT",
"FINALIZE_DELAY",
"SOCKET_PORT",
"WEBSOCKET_URL",
"GC_ENABLED",
"DB_COMPRESS_THRESHOLD",
"MAX_DOCUMENT_SIZE",
"ASSETS_ENABLED",
"ASSETS_SYNC_ENABLED",
"ASSETS_MAX_SIZE",
"ASSETS_MAX_SIZE_BYTES",
"ASSETS_ALLOWED_MIME_TYPES_LIST"
],
"properties": {
"SOCKET_PORT": {
"type": "number",
"default": 3345,
"description": "Web socket port for tldraw"
},
"WEBSOCKET_URL": {
"type": "string",
"default": "ws://localhost:3345",
"description": "Web socket url for tldraw"
},
"PING_TIMEOUT": {
"type": "number",
"default": 30000,
"description": "Websocket ping timeout in ms"
},
"FINALIZE_DELAY": {
"type": "number",
"default": 5000,
"description": "Delay in milliseconds before checking if can finalize a tldraw board"
},
"GC_ENABLED": {
"type": "boolean",
"default": true,
"description": "If tldraw garbage collector should be enabled"
},
"DB_COMPRESS_THRESHOLD": {
"type": "integer",
"default": 400,
"description": "Mongo documents with same docName compress threshold size"
},
"MAX_DOCUMENT_SIZE": {
"type": "number",
"default": 15000000,
"description": "Maximum size of a single tldraw document in mongo"
},
"ASSETS_ENABLED": {
"type": "boolean",
"default": true,
"description": "Enables uploading assets to tldraw board"
},
"ASSETS_SYNC_ENABLED": {
"type": "boolean",
"default": false,
"description": "Enables synchronization of tldraw board assets with file storage"
},
"ASSETS_MAX_SIZE": {
"ASSETS_MAX_SIZE_BYTES": {
"type": "integer",
"default": 10485760,
"description": "Maximum asset size in bytes"
},
"ASSETS_ALLOWED_MIME_TYPES_LIST": {
"type": "string",
"default": "image/png,image/jpeg,image/gif,image/svg+xml",
"description": "List with allowed assets MIME types, comma separated, empty if all MIME types supported by tldraw should be allowed",
"examples": ["image/gif,image/jpeg,video/webm"]
},
Expand All @@ -1586,18 +1602,6 @@
"description": "Define log level for tldraw.",
"enum": ["emerg", "alert", "crit", "error", "warning", "notice", "info", "debug"]
}
},
"default": {
"SOCKET_PORT": 3345,
"PING_TIMEOUT": 30000,
"FINALIZE_DELAY": 5000,
"GC_ENABLED": true,
"DB_COMPRESS_THRESHOLD": 400,
"MAX_DOCUMENT_SIZE": 15000000,
"ASSETS_ENABLED": true,
"ASSETS_SYNC_ENABLED": false,
"ASSETS_MAX_SIZE": 10485760,
"ASSETS_ALLOWED_MIME_TYPES_LIST": "image/png,image/jpeg,image/gif,image/svg+xml"
}
},
"TLDRAW_DB_URL": {
Expand Down
15 changes: 14 additions & 1 deletion config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,18 @@
"ALLOWED_API_KEYS": "thisisasupersecureapikeythatisabsolutelysave"
},
"TRAINING_URL": "https://lernen.dbildungscloud.de",
"FEATURE_ROOMS_ENABLED": true
"FEATURE_ROOMS_ENABLED": true,
"TLDRAW": {
"WEBSOCKET_URL": "ws://localhost:3345",
"SOCKET_PORT": 3346,
"PING_TIMEOUT": 1,
"FINALIZE_DELAY": 1,
"GC_ENABLED": true,
"DB_COMPRESS_THRESHOLD": 400,
"MAX_DOCUMENT_SIZE": 15000000,
"ASSETS_ENABLED": true,
"ASSETS_SYNC_ENABLED": true,
"ASSETS_MAX_SIZE_BYTES": 25000000,
"ASSETS_ALLOWED_MIME_TYPES_LIST": ""
}
}
3 changes: 2 additions & 1 deletion config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"VIDEOCONFERENCE_HOST": "https://bigbluebutton.schul-cloud.org/bigbluebutton",
"VIDEOCONFERENCE_SALT": "ThisIsNOTaRealSaltThisIsNOTaRealSaltThisIsNOTaRealSalt1234567890",
"TLDRAW": {
"WEBSOCKET_URL": "ws://localhost:3345",
"SOCKET_PORT": 3346,
"PING_TIMEOUT": 1,
"FINALIZE_DELAY": 1,
Expand All @@ -77,7 +78,7 @@
"MAX_DOCUMENT_SIZE": 15000000,
"ASSETS_ENABLED": true,
"ASSETS_SYNC_ENABLED": true,
"ASSETS_MAX_SIZE": 25000000,
"ASSETS_MAX_SIZE_BYTES": 25000000,
"ASSETS_ALLOWED_MIME_TYPES_LIST": ""
},
"SCHULCONNEX_CLIENT": {
Expand Down

0 comments on commit d567a04

Please sign in to comment.