Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Database Configuration
# When DATABASE_URL is set, PostgreSQL will be used automatically.
# Otherwise the backend falls back to local SQLite using DATABASE_PATH.
DATABASE_URL=postgresql://vaultix_user:vaultix_password@localhost:5432/vaultix_db
DATABASE_SSL=false
DATABASE_PATH=./data/vaultix.db

# JWT Configuration
Expand Down
174 changes: 156 additions & 18 deletions apps/backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"rxjs": "^7.8.1",
"socket.io": "^4.8.3",
"sqlite3": "^5.1.7",
"pg": "^8.11.0",
"stellar-sdk": "^13.3.0",
"swagger-ui-express": "^5.0.1",
"typeorm": "^0.3.28"
Expand Down
38 changes: 37 additions & 1 deletion apps/backend/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
import { Controller, Get } from '@nestjs/common';
import { InjectDataSource } from '@nestjs/typeorm';
import { DataSource } from 'typeorm';
import { AppService } from './app.service';

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(
private readonly appService: AppService,
@InjectDataSource()
private readonly dataSource: DataSource,
) {}

@Get()
getHello(): string {
return this.appService.getHello();
}

@Get('health/database')
async getDatabaseHealth() {
const dbType = this.dataSource.options.type;
const isConnected = this.dataSource.isInitialized;
let migrationCount = 0;
let migrationStatus = 'unknown';

try {
await this.dataSource.query('SELECT 1');
const result = await this.dataSource.query(

Check failure on line 28 in apps/backend/src/app.controller.ts

View workflow job for this annotation

GitHub Actions / Build and Test

Unsafe assignment of an `any` value
'SELECT COUNT(*) as count FROM "migrations"',
);
const countValue = Array.isArray(result) ? result[0]?.count : undefined;

Check failure on line 31 in apps/backend/src/app.controller.ts

View workflow job for this annotation

GitHub Actions / Build and Test

Unsafe member access .count on an `any` value

Check failure on line 31 in apps/backend/src/app.controller.ts

View workflow job for this annotation

GitHub Actions / Build and Test

Unsafe assignment of an `any` value
migrationCount = typeof countValue === 'string' ? Number(countValue) : Number(countValue || 0);
migrationStatus = Number.isFinite(migrationCount) ? 'ok' : 'unknown';
} catch (error) {
migrationStatus = 'unavailable';
}

Check failure on line 37 in apps/backend/src/app.controller.ts

View workflow job for this annotation

GitHub Actions / Build and Test

'error' is defined but never used
return {
status: isConnected ? 'ok' : 'down',
database: {
type: dbType,
connected: isConnected,
migrationStatus,
migrationsExecuted: migrationCount,
},
};
}
}
Loading
Loading