mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 05:26:47 +00:00
939452f9d8
* refactor(server): route every trip-access check through DatabaseService
Twelve Nest services carry the same verifyTripAccess/canEdit pair. Six already
asked DatabaseService.canAccessTrip; the other six went through
services/tripAccess, a nine-line re-export of the identical function. Same
query, same result, two ways to reach it.
All twelve now take the injected route, so services/tripAccess is gone.
The bigger duplication was in the types. Thirteen files declared their own
`Trip` for the same return value, in three different shapes:
NonNullable<ReturnType<typeof verifyTripAccess>> 6x
{ user_id: number } 4x
TripAccess 3x
The narrow one is why assignments, days, places and accommodations all wrote
`as Trip | null | undefined` on the call — the cast existed to shrink
TripAccess down to a local type that was never meant to differ from it. All
thirteen now say TripAccess, and the four casts are gone with no other change.
middleware/tripAccess.ts goes too: it was already dead in production — nothing
under src/ imported requireTripAccess or requireTripOwner, only comments in the
services that had absorbed them. Its test went with it.
* refactor(server): fold the query helpers and trip joins into the container
Two more legacy files whose only reason for staying outside the container was
that they predated it.
services/queryHelpers.ts held five exports doing two different jobs. Three are
the batch loaders that keep the list endpoints off N+1 queries — they hit the
database and are now QueryHelpersService over the injected connection, imported
by assignments, days, places and share. The other two, formatAssignmentWithPlace
and ratingAggregate, touch no database at all; they sat next to the loaders only
because the loaders were free functions too. Those stay free functions, in
common/rowShape.ts.
The README note on the assignments service claimed the loaders had to stay in
services/ because the day, share and place services were unmigrated. All three
have since moved, so the reason is gone.
services/tripMembership.ts becomes TripMembershipService in its own module. It
could have folded into auth or trip-invite, but both call it — as do oidc and
the plugin RPC host — and putting it in either would have made AuthModule and
TripInviteModule import each other.
Neither module is @Global, matching PermissionsModule: e2e TestingModules
resolve them transitively through each consumer's explicit import.
Test seams changed shape accordingly. Two path mocks of services/tripMembership
became injected stubs; the trip-invite e2e overrides the provider in the
container instead. The oidc test keeps the real implementation, which is what
OIDC-SVC-045 was always asserting.
ratingAggregate moved out of the ungated services/ tree into the coverage-gated
one, so it gets the direct tests it never had — as does the tags/participants
pass-through, which two long-dead fixture variables in the moved test file had
been waiting for.
Also drops four stale comments that outlived their subject: the requireTripAccess
middleware they pointed at was deleted in the previous commit.
68 lines
4.7 KiB
TypeScript
68 lines
4.7 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { PluginsController } from './plugins.controller';
|
|
import { PluginsFeedController } from './plugins-feed.controller';
|
|
import { PluginsProxyController } from './plugins-proxy.controller';
|
|
import { PluginFrameController } from './plugin-frame.controller';
|
|
import { PlaceDetailsController } from './place-details.controller';
|
|
import { TripWarningsController } from './trip-warnings.controller';
|
|
import { ViewContributionsController } from './view-contributions.controller';
|
|
import { TripCardContributionsController } from './trip-card-contributions.controller';
|
|
import { PluginPhotosController } from './plugin-photos.controller';
|
|
import { PluginCalendarController } from './plugin-calendar.controller';
|
|
import { MapMarkersController } from './map-markers.controller';
|
|
import { MapLayersController } from './map-layers.controller';
|
|
import { PluginRoutesController } from './plugin-routes.controller';
|
|
import { DayScheduleController } from './day-schedule.controller';
|
|
import { DayTintsController } from './day-tints.controller';
|
|
import { PluginActivityController } from './plugin-activity.controller';
|
|
import { PdfSectionsController } from './pdf-sections.controller';
|
|
import { AtlasLayersController } from './atlas-layers.controller';
|
|
import { JournalEntryRowsController } from './journal-entry-rows.controller';
|
|
import { PluginUserSettingsController } from './plugin-user-settings.controller';
|
|
import { PluginOAuthController } from './plugin-oauth.controller';
|
|
import { PluginOAuthService } from './plugin-oauth.service';
|
|
import { PluginsService } from './plugins.service';
|
|
import { PluginRuntimeService } from './plugin-runtime.service';
|
|
import { PluginRegistryService } from './registry/registry.service';
|
|
import { PluginHostDepsFactory } from './host/plugin-host-deps.factory';
|
|
import { TagsModule } from '../tags/tags.module';
|
|
import { CategoriesModule } from '../categories/categories.module';
|
|
import { BudgetModule } from '../budget/budget.module';
|
|
import { ReservationsModule } from '../reservations/reservations.module';
|
|
import { TodoModule } from '../todo/todo.module';
|
|
import { PackingModule } from '../packing/packing.module';
|
|
import { DaysModule } from '../days/days.module';
|
|
import { AssignmentsModule } from '../assignments/assignments.module';
|
|
import { LlmParseModule } from '../llm-parse/llm-parse.module';
|
|
import { FilesModule } from '../files/files.module';
|
|
import { CollabModule } from '../collab/collab.module';
|
|
import { VacayModule } from '../vacay/vacay.module';
|
|
import { TripsModule } from '../trips/trips.module';
|
|
import { PlacesModule } from '../places/places.module';
|
|
import { PermissionsModule } from '../permissions/permissions.module';
|
|
import { AuditModule } from '../audit/audit.module';
|
|
import { AddonsModule } from '../addons/addons.module';
|
|
import { CollectionsModule } from '../collections/collections.module';
|
|
import { AtlasModule } from '../atlas/atlas.module';
|
|
import { NotificationsModule } from '../notifications/notifications.module';
|
|
import { TripMembershipModule } from '../trip-membership/trip-membership.module';
|
|
|
|
/**
|
|
* Plugin system (#plugins). M0 read side + M2 isolated runtime + M3 frontend:
|
|
* the runtime service owns the process supervisor and boots active plugins on
|
|
* startup; the proxy forwards /api/plugins/:id/* to the child; the feed lists
|
|
* active plugins for the client; the frame controller serves sandboxed page/
|
|
* widget assets at /plugin-frame/:id/*.
|
|
*/
|
|
@Module({
|
|
// The DI-native domain services the plugin host wiring injects
|
|
// (PluginHostDepsFactory); DatabaseModule is @Global, so not listed.
|
|
imports: [TagsModule, CategoriesModule, BudgetModule, ReservationsModule, TodoModule, PackingModule, DaysModule, AssignmentsModule, LlmParseModule, FilesModule, CollabModule, VacayModule, TripsModule, PermissionsModule, AuditModule, AddonsModule, PlacesModule, CollectionsModule, AtlasModule, NotificationsModule, TripMembershipModule],
|
|
controllers: [PluginsController, PluginsFeedController, PluginsProxyController, PluginFrameController, PlaceDetailsController, TripWarningsController, ViewContributionsController, TripCardContributionsController, PluginPhotosController, PluginCalendarController, MapMarkersController, MapLayersController, PluginRoutesController, DayScheduleController, DayTintsController, PdfSectionsController, AtlasLayersController, JournalEntryRowsController, PluginUserSettingsController, PluginOAuthController, PluginActivityController],
|
|
providers: [PluginsService, PluginRuntimeService, PluginRegistryService, PluginOAuthService, PluginHostDepsFactory],
|
|
// Exported so the admin addon-toggle handler can cascade-disable plugins whose
|
|
// required addon was just turned off (#plugins dependencies).
|
|
exports: [PluginRuntimeService],
|
|
})
|
|
export class PluginsModule {}
|