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.
This commit is contained in:
Mathis H (Avnyr) 2024-09-23 14:17:25 +02:00
parent a9cd71995d
commit 0b66f9d3a3
Signed by: Mathis
GPG Key ID: DD9E0666A747D126
5 changed files with 73 additions and 6 deletions

View File

@ -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>(MachinesController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@ -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}
}
}

View File

@ -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 {}

View File

@ -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>(MachineService);
service = module.get<MachinesService>(MachinesService);
});
it('should be defined', () => {

View File

@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class MachineService {}
export class MachinesService {}