Skip to content

Commit

Permalink
fix(backend): singleton service instances
Browse files Browse the repository at this point in the history
  • Loading branch information
dr460nf1r3 committed Nov 3, 2024
1 parent 4682398 commit d546e67
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion backend/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { LocalStrategy } from "./local.strategy";

@Module({
controllers: [AuthController],
exports: [TypeOrmModule, PassportModule, JwtStrategy],
exports: [TypeOrmModule, PassportModule, JwtStrategy, AuthService],
imports: [
ConfigModule.forFeature(authConfig),
JwtModule.register({
Expand Down
14 changes: 6 additions & 8 deletions backend/src/builder/builder.module.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import { Module } from "@nestjs/common";
import { forwardRef, Module } from "@nestjs/common";
import { ConfigModule } from "@nestjs/config";
import { TypeOrmModule } from "@nestjs/typeorm";
import builderConfig from "../config/builder.config";
import { BuilderController } from "./builder.controller";
import { Build, Builder, Package, Repo } from "./builder.entity";
import { BuilderService } from "./builder.service";
import { RepoManagerModule } from "../repo-manager/repo-manager.module";
import { RepoManagerService } from "../repo-manager/repo-manager.service";
import { HttpModule } from "@nestjs/axios";
import { ArchlinuxPackage, RepoManagerSettings } from "../repo-manager/repo-manager.entity";
import { RepoManagerModule } from "../repo-manager/repo-manager.module";

@Module({
controllers: [BuilderController],
exports: [TypeOrmModule],
exports: [TypeOrmModule, BuilderService],
imports: [
ConfigModule.forFeature(builderConfig),
HttpModule,
RepoManagerModule,
TypeOrmModule.forFeature([Builder, Build, Repo, Package, ArchlinuxPackage, RepoManagerSettings]),
forwardRef(() => RepoManagerModule),
TypeOrmModule.forFeature([Builder, Build, Repo, Package]),
],
providers: [BuilderService, RepoManagerService],
providers: [BuilderService],
})
export class BuilderModule {}
3 changes: 2 additions & 1 deletion backend/src/metrics/metrics.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { MetricsController } from "./metrics.controller";
import { MetricsService } from "./metrics.service";

@Module({
imports: [CacheModule.register()],
controllers: [MetricsController],
exports: [MetricsService],
imports: [CacheModule.register()],
providers: [MetricsService],
})
export class MetricsModule {}
3 changes: 2 additions & 1 deletion backend/src/misc/misc.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { MiscController } from "./misc.controller";
import { MiscService } from "./misc.service";

@Module({
imports: [CacheModule.register()],
controllers: [MiscController],
exports: [MiscService],
imports: [CacheModule.register()],
providers: [MiscService],
})
export class MiscModule {}
12 changes: 7 additions & 5 deletions backend/src/repo-manager/repo-manager.module.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { Module } from "@nestjs/common";
import { forwardRef, Module } from "@nestjs/common";
import { RepoManagerController } from "./repo-manager.controller";
import { RepoManagerService } from "./repo-manager.service";
import { HttpModule } from "@nestjs/axios";
import { TypeOrmModule } from "@nestjs/typeorm";
import { ArchlinuxPackage, RepoManagerSettings } from "./repo-manager.entity";
import { ConfigModule } from "@nestjs/config";
import repoManagerConfig from "../config/repo-manager.config";
import { Package, Repo } from "../builder/builder.entity";
import { BuilderModule } from "../builder/builder.module";

@Module({
controllers: [RepoManagerController],
exports: [TypeOrmModule, RepoManagerService],
imports: [
HttpModule,
forwardRef(() => BuilderModule),
ConfigModule.forFeature(repoManagerConfig),
TypeOrmModule.forFeature([ArchlinuxPackage, Repo, RepoManagerSettings, Package]),
HttpModule,
TypeOrmModule.forFeature([ArchlinuxPackage, RepoManagerSettings]),
],
controllers: [RepoManagerController],
providers: [RepoManagerService],
})
export class RepoManagerModule {}
6 changes: 3 additions & 3 deletions backend/src/router/router.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { Package, Repo } from "../builder/builder.entity";
import { RouterController } from "./router.controller";
import { Mirror, RouterHit } from "./router.entity";
import { RouterService } from "./router.service";
import { APP_GUARD } from "@nestjs/core";
import { ThrottlerBehindProxyGuard } from "../api/throttler-behind-proxy.guard";
import { BuilderModule } from "../builder/builder.module";

@Module({
controllers: [RouterController],
exports: [TypeOrmModule],
imports: [TypeOrmModule.forFeature([RouterHit, Package, Repo, Mirror])],
exports: [RouterService, TypeOrmModule],
imports: [BuilderModule, TypeOrmModule.forFeature([RouterHit, Mirror])],
providers: [
RouterService,
{
Expand Down
3 changes: 2 additions & 1 deletion backend/src/telegram/telegram.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { TelegramController } from "./telegram.controller";
import { TelegramService } from "./telegram.service";

@Module({
imports: [CacheModule.register(), ConfigModule.forFeature(telegramConfig)],
controllers: [TelegramController],
exports: [TelegramService],
imports: [CacheModule.register(), ConfigModule.forFeature(telegramConfig)],
providers: [TelegramService],
})
export class TelegramModule {}
2 changes: 1 addition & 1 deletion backend/src/users/users.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { User } from "./users.entity";
import { UsersService } from "./users.service";

@Module({
exports: [TypeOrmModule],
exports: [TypeOrmModule, UsersService],
imports: [TypeOrmModule.forFeature([User])],
providers: [UsersService],
})
Expand Down

0 comments on commit d546e67

Please sign in to comment.