Files
TREK/server/src/nest/files/files.module.ts
T
Maurice 724c88c201 style: format server and shared with prettier
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.
2026-10-10 21:23:37 +02:00

72 lines
3.7 KiB
TypeScript

import { BudgetItems } from '../../db/entities/BudgetItems.entity';
import { DayAssignments } from '../../db/entities/DayAssignments.entity';
import { FileLinks } from '../../db/entities/FileLinks.entity';
import { Places } from '../../db/entities/Places.entity';
import { Reservations } from '../../db/entities/Reservations.entity';
import { TripFiles } from '../../db/entities/TripFiles.entity';
import { Trips } from '../../db/entities/Trips.entity';
import { Users } from '../../db/entities/Users.entity';
import { PluginGuardsModule } from '../../nest-rpc/plugin-guards.module';
import { AppConfigModule } from '../app-config/app-config.module';
import { EphemeralTokenModule } from '../auth-core/ephemeral-token.module';
import { McpSharedModule } from '../mcp-shared/mcp-shared.module';
import { PermissionsModule } from '../permissions/permissions.module';
import { RealtimeModule } from '../realtime/realtime.module';
import { buildStorageUploadOptions } from '../storage/storage-upload.factory';
import { StorageModule } from '../storage/storage.module';
import { StorageService } from '../storage/storage.service';
import { TripMembershipModule } from '../trip-membership/trip-membership.module';
import { AllowedFileTypesModule } from './allowed-file-types.module';
import { AllowedFileTypesService } from './allowed-file-types.service';
import { FilesDownloadController } from './files-download.controller';
import { MAX_FILE_SIZE, MAX_VIDEO_SIZE } from './files.constants';
import { FilesController } from './files.controller';
import { filesUploadFileFilter } from './files.controller';
import { FilesMcp } from './files.mcp';
import { FilesRpc } from './files.rpc';
import { FilesService } from './files.service';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';
import { MulterModule } from '@nestjs/platform-express';
@Module({
imports: [
TripMembershipModule,
MulterModule.registerAsync({
imports: [StorageModule, AllowedFileTypesModule],
inject: [StorageService, AllowedFileTypesService],
useFactory: (storage: StorageService, allowedTypes: AllowedFileTypesService) =>
buildStorageUploadOptions(storage, {
category: 'files',
// Allow up to the video cap; non-video files are still held to
// MAX_FILE_SIZE by the per-type guard in the upload handler (#823).
// An operator may raise the document limit past the video cap.
maxSize: Math.max(MAX_VIDEO_SIZE, MAX_FILE_SIZE),
defParamCharset: 'utf8', // parity with legacy routes/files.ts — preserve non-ASCII original filenames
fileFilter: filesUploadFileFilter(allowedTypes),
}),
}),
StorageModule,
// TripFiles/FileLinks are this domain's own tables (Plan 3e Task 1).
// Reservations/Places/DayAssignments/BudgetItems/Users are owned
// elsewhere — registered here only for `findForeignLinkTarget`'s
// `findTripId` reads and FL28's `UsersRepository.getEmail` (the entity
// classes only, never the owning module — the `AccommodationsDomainModule`
// precedent).
MikroOrmModule.forFeature([TripFiles, FileLinks, Reservations, Places, DayAssignments, BudgetItems, Users, Trips]),
// McpSharedModule feeds FilesMcp's RBAC guards; it is not @Global.
EphemeralTokenModule,
PermissionsModule,
AppConfigModule,
RealtimeModule,
PluginGuardsModule,
McpSharedModule,
// FilesMcp's upload tool checks the same extension list as the multipart filter.
AllowedFileTypesModule,
],
controllers: [FilesController, FilesDownloadController],
providers: [FilesService, FilesRpc, FilesMcp],
exports: [FilesService],
})
export class FilesModule {}