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:
parent
a9cd71995d
commit
0b66f9d3a3
20
apps/backend/src/app/machines/machines.controller.spec.ts
Normal file
20
apps/backend/src/app/machines/machines.controller.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
38
apps/backend/src/app/machines/machines.controller.ts
Normal file
38
apps/backend/src/app/machines/machines.controller.ts
Normal 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}
|
||||
|
||||
}
|
||||
}
|
9
apps/backend/src/app/machines/machines.module.ts
Normal file
9
apps/backend/src/app/machines/machines.module.ts
Normal 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 {}
|
@ -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', () => {
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class MachineService {}
|
||||
export class MachinesService {}
|
Loading…
x
Reference in New Issue
Block a user