refactor to adapters

This commit is contained in:
2025-12-15 18:34:20 +01:00
parent fc671482c8
commit c817d76092
145 changed files with 906 additions and 361 deletions

View File

@@ -0,0 +1,34 @@
import { SignupWithEmailUseCase } from '../../core/identity/application/use-cases/SignupWithEmailUseCase';
/**
* EnsureInitialData - Bootstrap script to ensure initial data exists.
* Idempotent: Can be run multiple times without issues.
* Calls core use cases to create initial admin user if not exists.
*/
export class EnsureInitialData {
constructor(
private readonly signupUseCase: SignupWithEmailUseCase,
) {}
async execute(): Promise<void> {
// Ensure initial admin user exists
try {
await this.signupUseCase.execute({
email: 'admin@gridpilot.local',
password: 'admin123',
displayName: 'Admin',
});
// User created successfully
} catch (error) {
if (error instanceof Error && error.message === 'An account with this email already exists') {
// User already exists, nothing to do
return;
}
// Re-throw other errors
throw error;
}
// Future: Add more initial data creation here
// e.g., create default league, config, etc.
}
}