mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-22 08:28:35 +00:00
* Better canvas * Better canvas * Better canvas * Fix for resize * Fix for drag * Fix for drag * Fix for drag * Adjust width of components by # of grid lines * Adjust components to comply with gridline based width * Fix the width of rigth sidebar * Fix for subcontainer resize issue * Fix for dropped widget width (sc) * Fix subcontainer drag width * Fix grid for sub container * Fix viewer * Fix * Fix * Use RnD for dragging within canvas * bounds for subcontainers * fix for subcontainers * Fix for mouseover issue * Fix * Fix widget widths * Fixes chart * Fixes qr scanner and divider * Remove scaleValue * Mmerge fix * Mmerge fix * Fix for ormconfig * Fixes for comments * Add comment where the user clicked * Disable dragging on viewer * Max width for canvas * Fix for widget click events * Fix for radio button * Rebase widget width and left offset for responsive canvas * Fix * Fix the width of file picker * Fix for calendar widget * Disable zoom selector * Fixes comment positions * css fixes * Fix * Recompute width and offset of subcontainer widgets based on its parent's width * Calculate container width separately for modal children while migrating to responsive * Refactor migration to responsive canvas whereinwhich all mutations are done only after all required changes are computed Co-authored-by: Sherfin Shamsudeen <sherfin94@gmail.com>
77 lines
2.2 KiB
TypeScript
77 lines
2.2 KiB
TypeScript
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
|
import * as path from 'path';
|
|
import * as dotenv from 'dotenv';
|
|
import * as fs from 'fs';
|
|
|
|
function buildConnectionOptions(filePath: string, env: string | undefined): TypeOrmModuleOptions {
|
|
let data: any = process.env;
|
|
|
|
if (fs.existsSync(filePath)) {
|
|
data = { ...data, ...dotenv.parse(fs.readFileSync(filePath)) };
|
|
}
|
|
|
|
/* use the database connection URL if available ( Heroku postgres addon uses connection URL ) */
|
|
|
|
const connectionParams = process.env.DATABASE_URL
|
|
? {
|
|
url: process.env.DATABASE_URL,
|
|
ssl: { rejectUnauthorized: false },
|
|
}
|
|
: {
|
|
database: data.PG_DB,
|
|
port: +data.PG_PORT || 5432,
|
|
username: data.PG_USER,
|
|
password: data.PG_PASS,
|
|
host: data.PG_HOST,
|
|
connectTimeoutMS: 5000,
|
|
extra: {
|
|
max: 25,
|
|
},
|
|
};
|
|
|
|
const entitiesDir =
|
|
process.env.NODE_ENV === 'test' ? [__dirname + '/**/*.entity.ts'] : [__dirname + '/**/*.entity{.js,.ts}'];
|
|
|
|
return {
|
|
type: 'postgres',
|
|
...connectionParams,
|
|
entities: entitiesDir,
|
|
synchronize: false,
|
|
uuidExtension: 'pgcrypto',
|
|
migrationsRun: false,
|
|
migrationsTransactionMode: 'each',
|
|
logging: data.ORM_LOGGING || false,
|
|
migrations: [__dirname + '/migrations/**/*{.ts,.js}'],
|
|
cli: {
|
|
migrationsDir: 'migrations',
|
|
},
|
|
};
|
|
}
|
|
|
|
function determineFilePathForEnv(env: string | undefined): string {
|
|
if (env === 'test') {
|
|
return path.resolve(process.cwd(), '../.env.test');
|
|
} else {
|
|
return path.resolve(process.cwd(), '../.env');
|
|
}
|
|
}
|
|
|
|
function throwErrorIfFileNotPresent(filePath: string, env: string): void {
|
|
if (!fs.existsSync(filePath)) {
|
|
console.log(
|
|
`Unable to fetch database config from env file for environment: ${env}\n` +
|
|
'Picking up config from the environment'
|
|
);
|
|
}
|
|
}
|
|
|
|
function fetchConnectionOptions(): TypeOrmModuleOptions {
|
|
const env: string | undefined = process.env.NODE_ENV;
|
|
const filePath: string = determineFilePathForEnv(env);
|
|
throwErrorIfFileNotPresent(filePath, env);
|
|
|
|
return buildConnectionOptions(filePath, env);
|
|
}
|
|
|
|
const ormconfig: TypeOrmModuleOptions = fetchConnectionOptions();
|
|
export default ormconfig;
|