Skip to content

Commit

Permalink
Fix collection name in tldraw db
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejpass committed Nov 17, 2023
1 parent 74bf209 commit 862a309
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion apps/server/src/config/database.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ interface GlobalConstants {
DB_URL: string;
DB_PASSWORD?: string;
DB_USERNAME?: string;
TLDRAW_DB_URL: string;
}

const usedGlobals: GlobalConstants = globals;

/** Database URL */
export const { DB_URL, DB_PASSWORD, DB_USERNAME } = usedGlobals;
export const { DB_URL, DB_PASSWORD, DB_USERNAME, TLDRAW_DB_URL } = usedGlobals;
4 changes: 2 additions & 2 deletions apps/server/src/modules/tldraw/tldraw.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module, NotFoundException } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions, DB_PASSWORD, DB_USERNAME, DB_URL } from '@src/config';
import { createConfigModuleOptions, DB_PASSWORD, DB_USERNAME, TLDRAW_DB_URL } from '@src/config';
import { CoreModule } from '@src/core';
import { Logger } from '@src/core/logger';
import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs';
Expand Down Expand Up @@ -30,7 +30,7 @@ const defaultMikroOrmOptions: MikroOrmModuleSyncOptions = {
MikroOrmModule.forRoot({
...defaultMikroOrmOptions,
type: 'mongo',
clientUrl: DB_URL,
clientUrl: TLDRAW_DB_URL,
password: DB_PASSWORD,
user: DB_USERNAME,
entities: [TldrawDrawing],
Expand Down
2 changes: 1 addition & 1 deletion config/default.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@
"SOCKET_PORT": 3345,
"PING_TIMEOUT": 10000,
"GC_ENABLED": true,
"DB_COLLECTION_NAME": "drawing",
"DB_COLLECTION_NAME": "drawings",
"DB_FLUSH_SIZE": 400,
"DB_MULTIPLE_COLLECTIONS": false
}
Expand Down
6 changes: 6 additions & 0 deletions config/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ switch (NODE_ENV) {
}

let defaultDbUrl = null;
let defaultTldrawDbUrl = null;
switch (NODE_ENV) {
case ENVIRONMENTS.TEST:
defaultDbUrl = 'mongodb://127.0.0.1:27017/schulcloud-test';
defaultTldrawDbUrl = 'mongodb://127.0.0.1:27017/tldraw-test';
break;
default:
defaultDbUrl = 'mongodb://127.0.0.1:27017/schulcloud';
defaultTldrawDbUrl = 'mongodb://127.0.0.1:27017/tldraw';
}

const globals = {
Expand Down Expand Up @@ -104,6 +107,9 @@ const globals = {

// calendar
CALENDAR_URI: process.env.CALENDAR_URI,

// tldraw
TLDRAW_DB_URL: process.env.TLDRAW_DB_URL || defaultTldrawDbUrl,
};

// validation /////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"SOCKET_PORT": 3346,
"PING_TIMEOUT": 1,
"GC_ENABLED": true,
"DB_COLLECTION_NAME": "drawing",
"DB_COLLECTION_NAME": "drawings",
"DB_FLUSH_SIZE": 400,
"DB_MULTIPLE_COLLECTIONS": false
}
Expand Down

0 comments on commit 862a309

Please sign in to comment.