From 0b66f9d3a32ed9cea292397c67e764ec6967dce7 Mon Sep 17 00:00:00 2001 From: Mathis Date: Mon, 23 Sep 2024 14:17:25 +0200 Subject: [PATCH] Rename MachineService to MachinesService and add Machines module Renamed MachineService to MachinesService across the codebase for consistency. Added MachinesController, MachinesModule, and associated tests to enhance modularity and structure. --- .../app/machines/machines.controller.spec.ts | 20 ++++++++++ .../src/app/machines/machines.controller.ts | 38 +++++++++++++++++++ .../src/app/machines/machines.module.ts | 9 +++++ .../machines.service.spec.ts} | 10 ++--- .../machines.service.ts} | 2 +- 5 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 apps/backend/src/app/machines/machines.controller.spec.ts create mode 100644 apps/backend/src/app/machines/machines.controller.ts create mode 100644 apps/backend/src/app/machines/machines.module.ts rename apps/backend/src/app/{machine/machine.service.spec.ts => machines/machines.service.spec.ts} (50%) rename apps/backend/src/app/{machine/machine.service.ts => machines/machines.service.ts} (65%) diff --git a/apps/backend/src/app/machines/machines.controller.spec.ts b/apps/backend/src/app/machines/machines.controller.spec.ts new file mode 100644 index 0000000..fc9d727 --- /dev/null +++ b/apps/backend/src/app/machines/machines.controller.spec.ts @@ -0,0 +1,20 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { MachinesController } from 'apps/backend/src/app/machines/machines.controller'; +import { MachinesService } from 'apps/backend/src/app/machines/machines.service'; + +describe('MachineController', () => { + let controller: MachinesController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [MachinesController], + providers: [MachinesService], + }).compile(); + + controller = module.get(MachinesController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/apps/backend/src/app/machines/machines.controller.ts b/apps/backend/src/app/machines/machines.controller.ts new file mode 100644 index 0000000..c5808e4 --- /dev/null +++ b/apps/backend/src/app/machines/machines.controller.ts @@ -0,0 +1,38 @@ +import { Controller, DefaultValuePipe, Delete, Get, Param, ParseIntPipe, Post, Query } from '@nestjs/common'; +import { MachinesService } from 'apps/backend/src/app/machines/machines.service'; + +@Controller('machines') +export class MachinesController { + constructor(private readonly machineService: MachinesService) {} + + @Get() + async findMany( + @Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number, + @Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number, + @Query("search", new DefaultValuePipe("")) search: string + ) { + const query = {limit, offset, search} + + } + + @Post("new") + async newMachine() { + + } + + @Delete(":machineId") + async deleteGroup(@Param('machineId') machineId: string) { + + } + + @Get(":groupId") + async getForGroup( + @Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number, + @Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number, + @Query("search", new DefaultValuePipe("")) search: string, + @Param('machineId') machineId: string + ) { + const query = {limit, offset, search} + + } +} diff --git a/apps/backend/src/app/machines/machines.module.ts b/apps/backend/src/app/machines/machines.module.ts new file mode 100644 index 0000000..6b84b65 --- /dev/null +++ b/apps/backend/src/app/machines/machines.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { MachinesService } from 'apps/backend/src/app/machines/machines.service'; +import { MachinesController } from 'apps/backend/src/app/machines/machines.controller'; + +@Module({ + controllers: [MachinesController], + providers: [MachinesService], +}) +export class MachinesModule {} diff --git a/apps/backend/src/app/machine/machine.service.spec.ts b/apps/backend/src/app/machines/machines.service.spec.ts similarity index 50% rename from apps/backend/src/app/machine/machine.service.spec.ts rename to apps/backend/src/app/machines/machines.service.spec.ts index f03b704..53a657a 100644 --- a/apps/backend/src/app/machine/machine.service.spec.ts +++ b/apps/backend/src/app/machines/machines.service.spec.ts @@ -1,15 +1,15 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { MachineService } from './machine.service'; +import { MachinesService } from 'apps/backend/src/app/machines/machines.service'; -describe('MachineService', () => { - let service: MachineService; +describe('MachinesService', () => { + let service: MachinesService; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ - providers: [MachineService], + providers: [MachinesService], }).compile(); - service = module.get(MachineService); + service = module.get(MachinesService); }); it('should be defined', () => { diff --git a/apps/backend/src/app/machine/machine.service.ts b/apps/backend/src/app/machines/machines.service.ts similarity index 65% rename from apps/backend/src/app/machine/machine.service.ts rename to apps/backend/src/app/machines/machines.service.ts index 2c7e101..165c8ba 100644 --- a/apps/backend/src/app/machine/machine.service.ts +++ b/apps/backend/src/app/machines/machines.service.ts @@ -1,4 +1,4 @@ import { Injectable } from '@nestjs/common'; @Injectable() -export class MachineService {} +export class MachinesService {}