9718d6888a
Build and Push Multi-Platform Images / build-and-push (push) Successful in 31s
Die Warteschlange liegt nicht mehr im Speicher, sondern in der neuen Tabelle webhook_queue (Entity WebhookQueueItem, documentId als Primärschlüssel). So überstehen ausstehende IDs einen Neustart und werden nach dem Boot weiterverarbeitet. - Neue Entity + Migration (CreateWebhookQueue); in data-source.ts/Barrel registriert. Dev: synchronize legt die Tabelle an; Prod: migrationsRun. - enqueue nutzt INSERT IGNORE (atomar, race-sicher) -> Dedup über den PK. - processQueue holt FIFO (createdAt ASC), entfernt die Zeile vor der Verarbeitung, arbeitet sequenziell (isProcessing-Guard). - getStatus/queueSize lesen die DB-Anzahl. Controller awaitet enqueue. - Unit-Test mit simuliertem FIFO-Repo: Dedup, Remove-on-start, Re-Enqueue, No-Parallel (deterministisch). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
84 lines
2.0 KiB
TypeScript
84 lines
2.0 KiB
TypeScript
import 'reflect-metadata';
|
|
import { join } from 'path';
|
|
import { config as loadEnv } from 'dotenv';
|
|
import { DataSource, DataSourceOptions } from 'typeorm';
|
|
import {
|
|
Client,
|
|
DocumentType,
|
|
DocumentField,
|
|
Task,
|
|
Postprocessing,
|
|
PostprocessingAction,
|
|
PostprocessingLog,
|
|
ExportTarget,
|
|
Setting,
|
|
Kontonummer,
|
|
Document,
|
|
UserClient,
|
|
Email,
|
|
Attachment,
|
|
Content,
|
|
ApiKey,
|
|
CorrespondentSetting,
|
|
BarcodeTemplate,
|
|
InboxDocument,
|
|
InboxPostprocessingAction,
|
|
CorrespondentEmailMapping,
|
|
UserSettings,
|
|
LabelPrintJob,
|
|
WebhookQueueItem,
|
|
} from './entities';
|
|
|
|
// CLI-Kontext: .env laden (Laufzeit im Container liefert die Variablen via Docker,
|
|
// dotenv ist dort ein No-Op). dotenv überschreibt bereits gesetzte Variablen nicht.
|
|
loadEnv();
|
|
loadEnv({ path: join(process.cwd(), '..', '.env') });
|
|
|
|
export const entities = [
|
|
Client,
|
|
DocumentType,
|
|
DocumentField,
|
|
Task,
|
|
Postprocessing,
|
|
PostprocessingAction,
|
|
PostprocessingLog,
|
|
ExportTarget,
|
|
Setting,
|
|
Kontonummer,
|
|
Document,
|
|
UserClient,
|
|
Email,
|
|
Attachment,
|
|
Content,
|
|
ApiKey,
|
|
CorrespondentSetting,
|
|
BarcodeTemplate,
|
|
InboxDocument,
|
|
InboxPostprocessingAction,
|
|
CorrespondentEmailMapping,
|
|
UserSettings,
|
|
LabelPrintJob,
|
|
WebhookQueueItem,
|
|
];
|
|
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
|
|
export const dataSourceOptions: DataSourceOptions = {
|
|
type: 'mysql',
|
|
host: process.env.DB_HOST ?? 'localhost',
|
|
port: Number(process.env.DB_PORT ?? 3306),
|
|
username: process.env.DB_USERNAME ?? 'root',
|
|
password: process.env.DB_PASSWORD ?? '',
|
|
database: process.env.DB_DATABASE ?? 'paperlessadd',
|
|
charset: 'utf8mb4',
|
|
entities,
|
|
migrations: [join(__dirname, 'migrations', '*.{ts,js}')],
|
|
// In Produktion: kein synchronize (zerstörerischer ALTER-Churn), Migrationen
|
|
// werden beim Start automatisch ausgeführt. In Dev: synchronize wie bisher.
|
|
synchronize: !isProduction,
|
|
migrationsRun: isProduction,
|
|
};
|
|
|
|
// Wird von der TypeORM-CLI verwendet (migration:generate / :run / :revert).
|
|
export default new DataSource(dataSourceOptions);
|