Skip to content

Commit 4c657aa

Browse files
authored
BC-7960 - Move config api to tldraw server (#23)
1 parent 1afb19c commit 4c657aa

File tree

18 files changed

+255
-37
lines changed

18 files changed

+255
-37
lines changed

.env.default

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ S3_PORT=9000
77
S3_SSL=false
88
S3_ACCESS_KEY=miniouser
99
S3_SECRET_KEY=miniouser
10+
11+
WS_PORT=3345
12+
13+
TLDRAW__WEBSOCKET_URL=ws://localhost:3345
14+
FEATURE_TLDRAW_ENABLED=true

.env.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ S3_PORT=9000
77
S3_SSL=false
88
S3_ACCESS_KEY=miniouser
99
S3_SECRET_KEY=miniouser
10+
11+
WS_PORT=3345
12+
13+
TLDRAW__WEBSOCKET_URL=ws://localhost:3345
14+
TLDRAW__ASSETS_ENABLED=true
15+
TLDRAW__ASSETS_MAX_SIZE_BYTES=10485760
16+
TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST="image/png,image/jpeg,image/gif,image/svg+xml"
17+
FEATURE_TLDRAW_ENABLED=true

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ jobs:
1414
- name: 'Dependency Review'
1515
uses: actions/dependency-review-action@v4
1616
with:
17-
allow-licenses: AGPL-3.0-only, LGPL-3.0, MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, X11, 0BSD, GPL-3.0, Unlicense, CC0-1.0
17+
allow-licenses: AGPL-3.0-only, LGPL-3.0, MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, X11, 0BSD, GPL-3.0, Unlicense, CC0-1.0, Python-2.0
1818
allow-dependencies-licenses: pkg:npm/%40y/redis

ansible/roles/tldraw-server/templates/configmap.yml.j2

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: ConfigMap
33
metadata:
44
name: tldraw-server-configmap
5-
namespace: {{ NAMESPACE }}
5+
namespace: "{{ NAMESPACE }}"
66
labels:
77
app: tldraw-server
88
data:
@@ -12,4 +12,9 @@ data:
1212
LOG: "@y/redis"
1313
FEATURE_PROMETHEUS_METRICS_ENABLED: "true"
1414
REDIS_CLUSTER_ENABLED: "true"
15-
REDIS_SENTINEL_SERVICE_NAME: valkey-headless.{{ NAMESPACE }}.svc.cluster.local
15+
REDIS_SENTINEL_SERVICE_NAME: "valkey-headless.{{ NAMESPACE }}.svc.cluster.local"
16+
TLDRAW__WEBSOCKET_URL: "wss://{{ DOMAIN }}/tldraw-server"
17+
TLDRAW__ASSETS_ENABLED: "true"
18+
TLDRAW__ASSETS_MAX_SIZE_BYTES: "10485760"
19+
TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST: "image/png,image/jpeg,image/gif,image/svg+xml"
20+
FEATURE_TLDRAW_ENABLED: "true"

ansible/roles/tldraw-server/templates/deployment.yml.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ spec:
5555
- containerPort: 3345
5656
name: tldraw-ws
5757
protocol: TCP
58+
- containerPort: 3349
59+
name: tldraw-http
60+
protocol: TCP
5861
- containerPort: 9090
5962
name: metrics
6063
protocol: TCP

ansible/roles/tldraw-server/templates/ingress.yml.j2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,10 @@ spec:
4141
port:
4242
number: 3345
4343
pathType: Prefix
44+
- path: /api/tldraw
45+
backend:
46+
service:
47+
name: tldraw-server-svc
48+
port:
49+
number: 3349
50+
pathType: Prefix

ansible/roles/tldraw-server/templates/server-svc.yml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@ spec:
1313
targetPort: 3345
1414
protocol: TCP
1515
name: tldraw-ws
16+
- port: 3349
17+
targetPort: 3349
18+
protocol: TCP
19+
name: tldraw-http
1620
selector:
1721
app: tldraw-server

package-lock.json

Lines changed: 67 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@nestjs/core": "^10.4.1",
3636
"@nestjs/passport": "^10.0.3",
3737
"@nestjs/platform-express": "^10.4.1",
38+
"@nestjs/swagger": "^7.4.2",
3839
"@y/redis": "github:hpi-schul-cloud/y-redis#7d48e08d18ec78c9ab90063a7d867ec7f191319c",
3940
"class-transformer": "^0.5.1",
4041
"class-validator": "^0.14.1",

src/apps/tldraw-server.app.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NestFactory } from '@nestjs/core';
2+
import { DocumentBuilder, SwaggerDocumentOptions, SwaggerModule } from '@nestjs/swagger';
23
import { Logger } from '../infra/logging/logger.js';
34
import { MetricsModule } from '../infra/metrics/metrics.module.js';
45
import { ServerModule } from '../modules/server/server.module.js';
@@ -8,6 +9,18 @@ async function bootstrap(): Promise<void> {
89
const nestApp = await NestFactory.create(ServerModule);
910
nestApp.setGlobalPrefix('api');
1011
nestApp.enableCors();
12+
13+
const options: SwaggerDocumentOptions = {
14+
operationIdFactory: (_controllerKey: string, methodKey: string) => methodKey,
15+
};
16+
17+
const config = new DocumentBuilder()
18+
.setTitle('Tldraw API')
19+
.setDescription('The Tldraw API to persist and share drawings')
20+
.build();
21+
const document = SwaggerModule.createDocument(nestApp, config, options);
22+
SwaggerModule.setup('docs', nestApp, document);
23+
1124
await nestApp.init();
1225

1326
const metricsPort = 9090;

0 commit comments

Comments
 (0)