Skip to content

Commit

Permalink
use TaskGateway instead of repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannbr committed Nov 18, 2024
1 parent 9056e63 commit 2bbfcbc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion apiv2/src/admin/Admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { QueueType } from "@shared/infra/Queue";
import { taskMongoProviders } from "@task/infra/TaskMongo.provider";
import { AdminTaskController } from "./infra/task/api/AdminTask.controller";
import { QueueModule } from "@infra/Queue.module";
import { TaskGateway } from "@task/core/Task.gateway";

@Module({
imports: [ClsModule.forRoot({}), DatabaseModule, JwtAuthModule, NotificationModule, QueueModule, TaskModule],
Expand All @@ -46,7 +47,7 @@ import { QueueModule } from "@infra/Queue.module";
SigninReferent,
{ provide: NotificationGateway, useClass: NotificationProducer },
{ provide: ContactGateway, useClass: ContactProducer },
AdminTaskRepository,
{ provide: TaskGateway, useClass: AdminTaskRepository },
...useCaseProviders,
...gatewayProviders,
],
Expand Down
11 changes: 6 additions & 5 deletions apiv2/src/admin/infra/task/api/AdminTask.controller.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
import { Body, Controller, Get, Param, Post, Put, UseGuards } from "@nestjs/common";
import { Body, Controller, Get, Inject, Param, Post, Put, UseGuards } from "@nestjs/common";
import { CreateTaskModel, TaskModel } from "@task/core/Task.model";
import { AdminTaskRepository } from "../AdminTaskMongo.repository";
import { SuperAdminGuard } from "../../iam/guard/SuperAdmin.guard";
import { TaskGateway } from "@task/core/Task.gateway";

@Controller("task")
export class AdminTaskController {
constructor(private adminTaskRepository: AdminTaskRepository) {}
constructor(@Inject(TaskGateway) private taskGateway: TaskGateway) {}

@Get("/")
@UseGuards(SuperAdminGuard)
findAll(): Promise<TaskModel[]> {
return this.adminTaskRepository.findAll();
return this.taskGateway.findAll();
}

@Get(":id")
@UseGuards(SuperAdminGuard)
verify(@Param("id") id: string): Promise<TaskModel> {
return this.adminTaskRepository.findById(id);
return this.taskGateway.findById(id);
}

// TODO for testing purposes only => REMOVE
@Post("/")
@UseGuards(SuperAdminGuard)
create(@Body() task: CreateTaskModel): Promise<TaskModel> {
return this.adminTaskRepository.create(task);
return this.taskGateway.create(task);
}
}
7 changes: 2 additions & 5 deletions apiv2/src/task/infra/TaskMongo.repository.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { InjectQueue } from "@nestjs/bullmq";
import { Inject, Injectable } from "@nestjs/common";
import { FunctionalException, FunctionalExceptionCode } from "@shared/core/FunctionalException";
import { Model } from "mongoose";
import { TaskStatus } from "snu-lib";
import { TaskGateway } from "src/task/core/Task.gateway";
import { CreateTaskModel, TaskModel } from "src/task/core/Task.model";
import { Queue } from "bullmq";
import { Model } from "mongoose";
import { TaskName, TaskStatus } from "snu-lib";
import { QueueType } from "../../shared/infra/Queue";
import { TaskMapper } from "./Task.mapper";
import { TASK_MONGOOSE_ENTITY, TaskDocument } from "./TaskMongo.provider";

Expand Down

0 comments on commit 2bbfcbc

Please sign in to comment.