()
| 77 | } |
| 78 | |
| 79 | async function main() { |
| 80 | const address = process.env.TEMPORAL_ADDRESS ?? 'localhost:7233'; |
| 81 | const taskQueue = process.env.TEMPORAL_TASK_QUEUE ?? 'shipsec-default'; |
| 82 | const namespace = process.env.TEMPORAL_NAMESPACE ?? 'shipsec-dev'; |
| 83 | const workflowsPath = join(dirname(fileURLToPath(import.meta.url)), '../workflows'); |
| 84 | |
| 85 | console.log(`🔌 Connecting to Temporal at ${address}...`); |
| 86 | console.log(`📋 Worker Configuration:`); |
| 87 | console.log(` - Address: ${address}`); |
| 88 | console.log(` - Namespace: ${namespace}`); |
| 89 | console.log(` - Task Queue: ${taskQueue}`); |
| 90 | console.log(` - Workflows Path: ${workflowsPath}`); |
| 91 | console.log(` - Node ENV: ${process.env.NODE_ENV}`); |
| 92 | |
| 93 | // Create connection first |
| 94 | console.log(`🔗 Establishing connection to Temporal...`); |
| 95 | const connection = await NativeConnection.connect({ |
| 96 | address, |
| 97 | }); |
| 98 | |
| 99 | console.log(`✅ Connected to Temporal at ${address}`); |
| 100 | |
| 101 | await ensureTemporalNamespace(connection, namespace); |
| 102 | |
| 103 | // Initialize database connection for worker |
| 104 | const connectionString = process.env.DATABASE_URL; |
| 105 | if (!connectionString) { |
| 106 | throw new ConfigurationError('DATABASE_URL is not set', { |
| 107 | configKey: 'DATABASE_URL', |
| 108 | }); |
| 109 | } |
| 110 | const pool = new Pool({ connectionString }); |
| 111 | const db = drizzle(pool, { schema }); |
| 112 | console.log(`✅ Connected to database`); |
| 113 | |
| 114 | // Initialize MinIO client |
| 115 | const minioEndpoint = process.env.MINIO_ENDPOINT ?? 'localhost'; |
| 116 | const minioPort = parseInt(process.env.MINIO_PORT ?? '9000', 10); |
| 117 | const minioAccessKey = process.env.MINIO_ACCESS_KEY ?? 'minioadmin'; |
| 118 | const minioSecretKey = process.env.MINIO_SECRET_KEY ?? 'minioadmin'; |
| 119 | const minioUseSSL = process.env.MINIO_USE_SSL === 'true'; |
| 120 | const minioBucketName = process.env.MINIO_BUCKET_NAME ?? 'shipsec-files'; |
| 121 | |
| 122 | const minioClient = new Client({ |
| 123 | endPoint: minioEndpoint, |
| 124 | port: minioPort, |
| 125 | useSSL: minioUseSSL, |
| 126 | accessKey: minioAccessKey, |
| 127 | secretKey: minioSecretKey, |
| 128 | }); |
| 129 | |
| 130 | console.log(`✅ Connected to MinIO at ${minioEndpoint}:${minioPort}`); |
| 131 | |
| 132 | // Create service adapters (implementing SDK interfaces) |
| 133 | const storageAdapter = new FileStorageAdapter(minioClient, db, minioBucketName); |
| 134 | const artifactAdapter = new ArtifactAdapter(minioClient, db, minioBucketName); |
| 135 | const secretsAdapter = new SecretsAdapter(db); |
| 136 |
no test coverage detected