Files
TREK/server/src/nest/collections/collections.module.ts
T
Maurice 1a9855cf70 refactor(mcp): the demo-mode write block runs once, in the registry's tool gate
Every write tool used to open with its own demo check, 196 copies across 30
tool files, most of them injecting AuthService for nothing else. The
registry now takes a toolGate (built from the container) that runs before
each registered tool handler, and TREK's gate refuses a demo account on
every tool not annotated read-only with the same canned result. The
per-tool checks, the AuthService injections, AuthService.isDemoUser and the
AuthModule imports that only fed them are gone; ESLint refuses a demo check
in a tool file, and a registry-wide test calls every write tool as the
demo account.
2026-10-10 20:15:57 +02:00

60 lines
3.2 KiB
TypeScript

import { Module } from '@nestjs/common';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Collections } from '../../db/entities/Collections.entity';
import { CollectionMembers } from '../../db/entities/CollectionMembers.entity';
import { CollectionLabels } from '../../db/entities/CollectionLabels.entity';
import { CollectionPlaces } from '../../db/entities/CollectionPlaces.entity';
import { CollectionPlaceRatings } from '../../db/entities/CollectionPlaceRatings.entity';
import { Categories } from '../../db/entities/Categories.entity';
import { Users } from '../../db/entities/Users.entity';
import { Trips } from '../../db/entities/Trips.entity';
import { TripMembers } from '../../db/entities/TripMembers.entity';
import { Places } from '../../db/entities/Places.entity';
import { PlaceRatings } from '../../db/entities/PlaceRatings.entity';
import { Tags } from '../../db/entities/Tags.entity';
import { CollectionsController } from './collections.controller';
import { CollectionsService } from './collections.service';
import { CollectionsRpc } from './collections.rpc';
import { PluginGuardsModule } from '../plugins/host/plugin-guards.module';
import { AppConfigModule } from '../app-config/app-config.module';
import { CollectionsMcp } from './collections.mcp';
import { AddonsModule } from '../addons/addons.module';
import { PermissionsModule } from '../permissions/permissions.module';
import { NotificationsModule } from '../notifications/notifications.module';
import { MulterModule } from '@nestjs/platform-express';
import { StorageModule } from '../storage/storage.module';
import { StorageService } from '../storage/storage.service';
import { buildStorageUploadOptions } from '../storage/storage-upload.factory';
import { MAX_COVER_SIZE } from './collections.controller';
/** Collections domain (saved-places library). Registered in AppModule.
* Exports CollectionsService for in-container consumers (PluginsModule's
* RPC host deps factory). */
@Module({
imports: [
// Two upload routes, two categories: the per-file resolver routes each part
// to the right spool. Fieldname routing is exact — FileInterceptor('cover')/
// FileInterceptor('image') reject any other part with LIMIT_UNEXPECTED_FILE
// before the storage callbacks run. Both routes pass their fileFilter
// inline (cover keeps its plain-Error 500 quirk; image its statusCode 400).
MulterModule.registerAsync({
imports: [StorageModule],
inject: [StorageService],
useFactory: (storage: StorageService) =>
buildStorageUploadOptions(storage, {
category: (_req, file) => (file.fieldname === 'image' ? 'places' : 'covers'),
maxSize: MAX_COVER_SIZE, // same 20 MB cap for covers and place images
}),
}),
StorageModule,
NotificationsModule, AddonsModule, PermissionsModule, AppConfigModule, PluginGuardsModule,
MikroOrmModule.forFeature([
Collections, CollectionMembers, CollectionLabels, CollectionPlaces, CollectionPlaceRatings,
Categories, Users, Trips, TripMembers, Places, PlaceRatings, Tags,
])],
controllers: [CollectionsController],
providers: [CollectionsService, CollectionsMcp, CollectionsRpc],
exports: [CollectionsService],
})
export class CollectionsModule {}