chore: configure angular and postgres foundation

This commit is contained in:
Bastian Wagner
2026-08-18 18:02:40 +02:00
parent 4a689238e6
commit 2903a0d670
11 changed files with 6314 additions and 1117 deletions

View File

@@ -0,0 +1,18 @@
import { createDatabaseConfig } from './database.config';
describe('createDatabaseConfig', () => {
it('uses postgres and permanently disables synchronization', () => {
expect(
createDatabaseConfig('postgresql://test:test@localhost/test'),
).toMatchObject({
type: 'postgres',
url: 'postgresql://test:test@localhost/test',
synchronize: false,
autoLoadEntities: true,
});
});
it('rejects an empty database URL', () => {
expect(() => createDatabaseConfig('')).toThrow('DATABASE_URL is required');
});
});

View File

@@ -0,0 +1,16 @@
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
export function createDatabaseConfig(
databaseUrl: string,
): TypeOrmModuleOptions {
if (!databaseUrl.trim()) {
throw new Error('DATABASE_URL is required');
}
return {
type: 'postgres',
url: databaseUrl,
autoLoadEntities: true,
synchronize: false,
};
}