feat: Add Jimeng image generation service and related functionality

- Implemented JimengService for image generation with API integration.
- Created OSSService for handling image uploads to S3.
- Developed PBService for managing PocketBase interactions.
- Added task management for image creation and downloading using BullMQ.
- Introduced routes for creating image generation tasks.
- Implemented logging and error handling for image processing.
- Added configuration management for Redis and other services.
- Created scripts for testing image generation and PocketBase integration.
- Updated package dependencies and added new scripts for worker management.
This commit is contained in:
2026-01-09 02:55:04 +08:00
parent 7cca41b457
commit 9da3d14752
31 changed files with 3193 additions and 5 deletions

View File

@@ -0,0 +1,28 @@
import { IMAGE_DOWNLOAD_JOB } from '../src/task/image-creator.job'
import { Worker, Queue, Job } from 'bullmq';
import { getRedisConnection } from '../src/module/redis.ts';
import { pbService, jimengService, ossService } from '../src/index.ts';
const connection = getRedisConnection();
const queue = new Queue(IMAGE_DOWNLOAD_JOB, { connection });
// 显示错误的尝试任务, queue列出来
async function showFailedJobs() {
const failedJobs = await queue.getFailed();
if (failedJobs.length === 0) {
console.log('No failed jobs found.');
return;
}
console.log(`Found ${failedJobs.length} failed jobs:`);
for (const job of failedJobs) {
console.log(`- Job ID: ${job.id}, Attempts Made: ${job.attemptsMade}, Data: ${JSON.stringify(job.data)}`);
}
}
showFailedJobs().then(() => {
process.exit(0);
}).catch((error) => {
console.error('Error showing failed jobs:', error);
process.exit(1);
});