make sure it is really relative path, even when started from root folder

This commit is contained in:
einhornimmond 2025-05-16 10:32:23 +02:00
parent 1b10ce7f09
commit 3dda798ad1
3 changed files with 7 additions and 5 deletions

View File

@ -3,6 +3,7 @@
import { entities } from 'database'
import { Connection as DbConnection, FileLogger, createConnection } from 'typeorm'
import path from 'node:path'
import { CONFIG } from '@/config'
export class Connection {
@ -38,7 +39,7 @@ export class Connection {
synchronize: false,
logging: true,
logger: new FileLogger('all', {
logPath: CONFIG.TYPEORM_LOGGING_RELATIVE_PATH,
logPath: path.resolve(__dirname, CONFIG.TYPEORM_LOGGING_RELATIVE_PATH),
}),
extra: {
charset: 'utf8mb4_unicode_ci',

View File

@ -1,10 +1,10 @@
import path from 'node:path'
import { CONFIG } from '@/config'
// TODO This is super weird - since the entities are defined in another project they have their own globals.
// We cannot use our connection here, but must use the external typeorm installation
import { entities } from 'database'
import { Connection, FileLogger, createConnection } from 'typeorm'
import { CONFIG } from '@/config'
export const connection = async (): Promise<Connection | null> => {
try {
return createConnection({
@ -19,7 +19,7 @@ export const connection = async (): Promise<Connection | null> => {
synchronize: false,
logging: true,
logger: new FileLogger('all', {
logPath: CONFIG.TYPEORM_LOGGING_RELATIVE_PATH,
logPath: path.resolve(__dirname, CONFIG.TYPEORM_LOGGING_RELATIVE_PATH),
}),
extra: {
charset: 'utf8mb4_unicode_ci',

View File

@ -1,3 +1,4 @@
import path from 'node:path'
import { CONFIG } from '@/config'
// TODO This is super weird - since the entities are defined in another project they have their own globals.
// We cannot use our connection here, but must use the external typeorm installation
@ -18,7 +19,7 @@ const connection = async (): Promise<Connection | null> => {
synchronize: false,
logging: true,
logger: new FileLogger('all', {
logPath: CONFIG.TYPEORM_LOGGING_RELATIVE_PATH,
logPath: path.resolve(__dirname, CONFIG.TYPEORM_LOGGING_RELATIVE_PATH),
}),
extra: {
charset: 'utf8mb4_unicode_ci',