mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
724c88c201
A mechanical prettier --write over server/src, server/tests, server/scripts and shared/src with the workspaces' .prettierrc; nothing but layout and import order changes, and every file keeps the same set of imports. shared is formatted throughout and its format baseline is empty. The server baseline keeps the 35 files that Prettier would grow past their lint:size limit (they need a split first, which is not a formatting change), and the generated entity files stay as their generator writes them.
51 lines
2.0 KiB
TypeScript
51 lines
2.0 KiB
TypeScript
import { AppConfigModule } from '../app-config/app-config.module';
|
|
import { AuditModule } from '../audit/audit.module';
|
|
import { SchedulingModule } from '../scheduling/scheduling.module';
|
|
import { StorageModule } from '../storage/storage.module';
|
|
import { StorageService } from '../storage/storage.service';
|
|
import { AutoBackupJob } from './auto-backup.job';
|
|
import { BackupController } from './backup.controller';
|
|
import { MAX_BACKUP_UPLOAD_SIZE } from './backup.impl';
|
|
import { BackupService } from './backup.service';
|
|
import { DatabaseBackupModule } from './database-backup.module';
|
|
import { Module } from '@nestjs/common';
|
|
import { MulterModule } from '@nestjs/platform-express';
|
|
import type { MulterOptions } from '@nestjs/platform-express/multer/interfaces/multer-options.interface';
|
|
|
|
/**
|
|
* Multer options for the restore upload. The uploaded zip is a restore INPUT,
|
|
* not a stored object — it gets no storage category and spools to the
|
|
* driver-agnostic scratch dir (data/tmp), where the handler consumes and
|
|
* unlinks it. Resolved through DI so no path is computed at module load.
|
|
*/
|
|
export function buildBackupUploadOptions(storage: StorageService): MulterOptions {
|
|
return {
|
|
dest: storage.tempDir(),
|
|
fileFilter: (_req: unknown, file: Express.Multer.File, cb: (err: Error | null, accept: boolean) => void) => {
|
|
if (file.originalname.endsWith('.zip')) return cb(null, true);
|
|
cb(new Error('Only ZIP files allowed'), false);
|
|
},
|
|
limits: { fileSize: MAX_BACKUP_UPLOAD_SIZE },
|
|
};
|
|
}
|
|
|
|
@Module({
|
|
imports: [
|
|
AppConfigModule,
|
|
AuditModule,
|
|
// Global, so the admin domain sees the port too; imported here because the
|
|
// backup domain is what it belongs to.
|
|
DatabaseBackupModule,
|
|
SchedulingModule,
|
|
StorageModule,
|
|
MulterModule.registerAsync({
|
|
imports: [StorageModule],
|
|
inject: [StorageService],
|
|
useFactory: buildBackupUploadOptions,
|
|
}),
|
|
],
|
|
controllers: [BackupController],
|
|
providers: [BackupService, AutoBackupJob],
|
|
})
|
|
export class BackupModule {}
|