From 0a651ea8917c7d10e66ae773f20fac25e26a4ccc Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 12:11:53 +0900 Subject: [PATCH 01/12] yarn nest g resource room --- backend/src/app.module.ts | 3 ++- backend/src/room/dto/create-room.dto.ts | 1 + backend/src/room/dto/update-room.dto.ts | 4 +++ backend/src/room/entities/room.entity.ts | 1 + backend/src/room/room.controller.spec.ts | 20 ++++++++++++++ backend/src/room/room.controller.ts | 34 ++++++++++++++++++++++++ backend/src/room/room.module.ts | 9 +++++++ backend/src/room/room.service.spec.ts | 18 +++++++++++++ backend/src/room/room.service.ts | 26 ++++++++++++++++++ 9 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 backend/src/room/dto/create-room.dto.ts create mode 100644 backend/src/room/dto/update-room.dto.ts create mode 100644 backend/src/room/entities/room.entity.ts create mode 100644 backend/src/room/room.controller.spec.ts create mode 100644 backend/src/room/room.controller.ts create mode 100644 backend/src/room/room.module.ts create mode 100644 backend/src/room/room.service.spec.ts create mode 100644 backend/src/room/room.service.ts diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index a44e1275..47c85030 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -4,9 +4,10 @@ import { AppService } from './app.service'; import { UserModule } from './user/user.module'; import { PrismaModule } from './prisma/prisma.module'; import { AuthModule } from './auth/auth.module'; +import { RoomModule } from './room/room.module'; @Module({ - imports: [UserModule, PrismaModule, AuthModule], + imports: [UserModule, PrismaModule, AuthModule, RoomModule], controllers: [AppController], providers: [AppService], }) diff --git a/backend/src/room/dto/create-room.dto.ts b/backend/src/room/dto/create-room.dto.ts new file mode 100644 index 00000000..857bfd87 --- /dev/null +++ b/backend/src/room/dto/create-room.dto.ts @@ -0,0 +1 @@ +export class CreateRoomDto {} diff --git a/backend/src/room/dto/update-room.dto.ts b/backend/src/room/dto/update-room.dto.ts new file mode 100644 index 00000000..294bd61a --- /dev/null +++ b/backend/src/room/dto/update-room.dto.ts @@ -0,0 +1,4 @@ +import { PartialType } from '@nestjs/swagger'; +import { CreateRoomDto } from './create-room.dto'; + +export class UpdateRoomDto extends PartialType(CreateRoomDto) {} diff --git a/backend/src/room/entities/room.entity.ts b/backend/src/room/entities/room.entity.ts new file mode 100644 index 00000000..956fadaa --- /dev/null +++ b/backend/src/room/entities/room.entity.ts @@ -0,0 +1 @@ +export class Room {} diff --git a/backend/src/room/room.controller.spec.ts b/backend/src/room/room.controller.spec.ts new file mode 100644 index 00000000..85b65b7e --- /dev/null +++ b/backend/src/room/room.controller.spec.ts @@ -0,0 +1,20 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { RoomController } from './room.controller'; +import { RoomService } from './room.service'; + +describe('RoomController', () => { + let controller: RoomController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [RoomController], + providers: [RoomService], + }).compile(); + + controller = module.get(RoomController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/backend/src/room/room.controller.ts b/backend/src/room/room.controller.ts new file mode 100644 index 00000000..08462b1e --- /dev/null +++ b/backend/src/room/room.controller.ts @@ -0,0 +1,34 @@ +import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; +import { RoomService } from './room.service'; +import { CreateRoomDto } from './dto/create-room.dto'; +import { UpdateRoomDto } from './dto/update-room.dto'; + +@Controller('room') +export class RoomController { + constructor(private readonly roomService: RoomService) {} + + @Post() + create(@Body() createRoomDto: CreateRoomDto) { + return this.roomService.create(createRoomDto); + } + + @Get() + findAll() { + return this.roomService.findAll(); + } + + @Get(':id') + findOne(@Param('id') id: string) { + return this.roomService.findOne(+id); + } + + @Patch(':id') + update(@Param('id') id: string, @Body() updateRoomDto: UpdateRoomDto) { + return this.roomService.update(+id, updateRoomDto); + } + + @Delete(':id') + remove(@Param('id') id: string) { + return this.roomService.remove(+id); + } +} diff --git a/backend/src/room/room.module.ts b/backend/src/room/room.module.ts new file mode 100644 index 00000000..f6206e6f --- /dev/null +++ b/backend/src/room/room.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { RoomService } from './room.service'; +import { RoomController } from './room.controller'; + +@Module({ + controllers: [RoomController], + providers: [RoomService], +}) +export class RoomModule {} diff --git a/backend/src/room/room.service.spec.ts b/backend/src/room/room.service.spec.ts new file mode 100644 index 00000000..504502bb --- /dev/null +++ b/backend/src/room/room.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { RoomService } from './room.service'; + +describe('RoomService', () => { + let service: RoomService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [RoomService], + }).compile(); + + service = module.get(RoomService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/backend/src/room/room.service.ts b/backend/src/room/room.service.ts new file mode 100644 index 00000000..72ebbcb6 --- /dev/null +++ b/backend/src/room/room.service.ts @@ -0,0 +1,26 @@ +import { Injectable } from '@nestjs/common'; +import { CreateRoomDto } from './dto/create-room.dto'; +import { UpdateRoomDto } from './dto/update-room.dto'; + +@Injectable() +export class RoomService { + create(createRoomDto: CreateRoomDto) { + return 'This action adds a new room'; + } + + findAll() { + return `This action returns all room`; + } + + findOne(id: number) { + return `This action returns a #${id} room`; + } + + update(id: number, updateRoomDto: UpdateRoomDto) { + return `This action updates a #${id} room`; + } + + remove(id: number) { + return `This action removes a #${id} room`; + } +} From 1290b767342310c5bc286cb854506ca8d4b5b018 Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 14:27:17 +0900 Subject: [PATCH 02/12] add new model room yarn prisma migrate dev -name room --- .../prisma/migrations/20231109052515_room/migration.sql | 7 +++++++ backend/prisma/schema.prisma | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 backend/prisma/migrations/20231109052515_room/migration.sql diff --git a/backend/prisma/migrations/20231109052515_room/migration.sql b/backend/prisma/migrations/20231109052515_room/migration.sql new file mode 100644 index 00000000..1fb69f84 --- /dev/null +++ b/backend/prisma/migrations/20231109052515_room/migration.sql @@ -0,0 +1,7 @@ +-- CreateTable +CREATE TABLE "Room" ( + "id" SERIAL NOT NULL, + "name" TEXT NOT NULL, + + CONSTRAINT "Room_pkey" PRIMARY KEY ("id") +); diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index 2016f4c3..05562a92 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -16,3 +16,8 @@ model User { name String? password String } + +model Room { + id Int @id @default(autoincrement()) + name String +} \ No newline at end of file From 48a901663411fe9676ed4dec0e3b30fb2909d217 Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 16:05:09 +0900 Subject: [PATCH 03/12] seed room data --- backend/prisma/seed.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/backend/prisma/seed.ts b/backend/prisma/seed.ts index 279b4005..3743c4ed 100644 --- a/backend/prisma/seed.ts +++ b/backend/prisma/seed.ts @@ -56,6 +56,22 @@ async function main() { }); console.log({ user1, user2, user3, user4 }); + + const room1 = await prisma.room.upsert({ + where: { id: 1 }, + update: {}, + create: { + name: 'Room 1', + }, + }); + const room2 = await prisma.room.upsert({ + where: { id: 2 }, + update: {}, + create: { + name: 'Room 2', + }, + }); + } main() From 64919473ba9dacb246243d47b08ac3ad3b234aad Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 16:13:01 +0900 Subject: [PATCH 04/12] implement findAll() findOne() room model define --- backend/src/room/dto/create-room.dto.ts | 5 ++++- backend/src/room/room.controller.ts | 10 +++++++++- backend/src/room/room.module.ts | 2 ++ backend/src/room/room.service.ts | 9 ++++++--- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/backend/src/room/dto/create-room.dto.ts b/backend/src/room/dto/create-room.dto.ts index 857bfd87..b429489a 100644 --- a/backend/src/room/dto/create-room.dto.ts +++ b/backend/src/room/dto/create-room.dto.ts @@ -1 +1,4 @@ -export class CreateRoomDto {} +export class CreateRoomDto { + id: number; + name: string; +} diff --git a/backend/src/room/room.controller.ts b/backend/src/room/room.controller.ts index 08462b1e..ec7ac948 100644 --- a/backend/src/room/room.controller.ts +++ b/backend/src/room/room.controller.ts @@ -1,4 +1,12 @@ -import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; +import { + Controller, + Get, + Post, + Body, + Patch, + Param, + Delete, +} from '@nestjs/common'; import { RoomService } from './room.service'; import { CreateRoomDto } from './dto/create-room.dto'; import { UpdateRoomDto } from './dto/update-room.dto'; diff --git a/backend/src/room/room.module.ts b/backend/src/room/room.module.ts index f6206e6f..c8f36bfb 100644 --- a/backend/src/room/room.module.ts +++ b/backend/src/room/room.module.ts @@ -1,9 +1,11 @@ import { Module } from '@nestjs/common'; import { RoomService } from './room.service'; import { RoomController } from './room.controller'; +import { PrismaModule } from 'src/prisma/prisma.module'; @Module({ controllers: [RoomController], providers: [RoomService], + imports: [PrismaModule], }) export class RoomModule {} diff --git a/backend/src/room/room.service.ts b/backend/src/room/room.service.ts index 72ebbcb6..61334a11 100644 --- a/backend/src/room/room.service.ts +++ b/backend/src/room/room.service.ts @@ -1,19 +1,22 @@ import { Injectable } from '@nestjs/common'; import { CreateRoomDto } from './dto/create-room.dto'; import { UpdateRoomDto } from './dto/update-room.dto'; +import { PrismaService } from 'src/prisma/prisma.service'; @Injectable() export class RoomService { + constructor(private prisma: PrismaService) {} + create(createRoomDto: CreateRoomDto) { - return 'This action adds a new room'; + return this.prisma.room.create({ data: createRoomDto }); } findAll() { - return `This action returns all room`; + return this.prisma.room.findMany(); } findOne(id: number) { - return `This action returns a #${id} room`; + return this.prisma.room.findUniqueOrThrow({ where: { id: id } }); } update(id: number, updateRoomDto: UpdateRoomDto) { From e12141eb0633e4f05d5f297660fcc710c6300478 Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 16:36:06 +0900 Subject: [PATCH 05/12] =?UTF-8?q?implement=20create()=20(room)=20create(@B?= =?UTF-8?q?ody()=20createRoomDto:=20CreateRoomDto)=20=E3=81=A0=E3=81=A8?= =?UTF-8?q?=E3=81=86=E3=81=BE=E3=81=8F=E3=81=84=E3=81=8B=E3=81=9A=20?= =?UTF-8?q?=E4=B8=80=E6=97=A6=E3=80=81any=20=E3=81=A7=E5=8F=97=E3=81=91?= =?UTF-8?q?=E5=8F=96=E3=81=A3=E3=81=A6=E3=81=8B=E3=82=89create()=20?= =?UTF-8?q?=E3=81=AB=E6=B8=A1=E3=81=99=E3=81=A8=E6=88=90=E5=8A=9F=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/room/dto/create-room.dto.ts | 5 +++++ backend/src/room/room.controller.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/room/dto/create-room.dto.ts b/backend/src/room/dto/create-room.dto.ts index b429489a..55e2e333 100644 --- a/backend/src/room/dto/create-room.dto.ts +++ b/backend/src/room/dto/create-room.dto.ts @@ -1,4 +1,9 @@ +import {ApiProperty, ApiPropertyOptional} from '@nestjs/swagger'; + export class CreateRoomDto { + @ApiProperty() id: number; + + @ApiProperty() name: string; } diff --git a/backend/src/room/room.controller.ts b/backend/src/room/room.controller.ts index ec7ac948..67ecf816 100644 --- a/backend/src/room/room.controller.ts +++ b/backend/src/room/room.controller.ts @@ -16,8 +16,8 @@ export class RoomController { constructor(private readonly roomService: RoomService) {} @Post() - create(@Body() createRoomDto: CreateRoomDto) { - return this.roomService.create(createRoomDto); + create(@Body() body: any) { + return this.roomService.create(body); } @Get() From 97faa73ac9a887063b4867c0c3b9c036f6ff157e Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 16:47:40 +0900 Subject: [PATCH 06/12] implement remove() group api in swagger --- backend/src/room/room.controller.ts | 2 ++ backend/src/room/room.service.ts | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/room/room.controller.ts b/backend/src/room/room.controller.ts index 67ecf816..2f2263a4 100644 --- a/backend/src/room/room.controller.ts +++ b/backend/src/room/room.controller.ts @@ -10,8 +10,10 @@ import { import { RoomService } from './room.service'; import { CreateRoomDto } from './dto/create-room.dto'; import { UpdateRoomDto } from './dto/update-room.dto'; +import { ApiTags } from '@nestjs/swagger'; @Controller('room') +@ApiTags('room') export class RoomController { constructor(private readonly roomService: RoomService) {} diff --git a/backend/src/room/room.service.ts b/backend/src/room/room.service.ts index 61334a11..0c0caf04 100644 --- a/backend/src/room/room.service.ts +++ b/backend/src/room/room.service.ts @@ -20,10 +20,13 @@ export class RoomService { } update(id: number, updateRoomDto: UpdateRoomDto) { - return `This action updates a #${id} room`; + return this.prisma.room.update({ + where: { id }, + data: updateRoomDto, + }); } remove(id: number) { - return `This action removes a #${id} room`; + return this.prisma.room.delete({ where: { id }}); } } From 0543e2fc05d04875b869abc3271dc3dc1fae773d Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 17:05:14 +0900 Subject: [PATCH 07/12] add room entity add swagger decorator to display right response type --- backend/src/room/entities/room.entity.ts | 11 ++++++++++- backend/src/room/room.controller.ts | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/backend/src/room/entities/room.entity.ts b/backend/src/room/entities/room.entity.ts index 956fadaa..009b1cf5 100644 --- a/backend/src/room/entities/room.entity.ts +++ b/backend/src/room/entities/room.entity.ts @@ -1 +1,10 @@ -export class Room {} +import { Room } from '@prisma/client'; +import {ApiProperty} from '@nestjs/swagger'; + +export class RoomEntity implements Room { + @ApiProperty() + id: number; + + @ApiProperty() + name: string; +} diff --git a/backend/src/room/room.controller.ts b/backend/src/room/room.controller.ts index 2f2263a4..348aaf12 100644 --- a/backend/src/room/room.controller.ts +++ b/backend/src/room/room.controller.ts @@ -10,7 +10,8 @@ import { import { RoomService } from './room.service'; import { CreateRoomDto } from './dto/create-room.dto'; import { UpdateRoomDto } from './dto/update-room.dto'; -import { ApiTags } from '@nestjs/swagger'; +import { ApiTags, ApiCreatedResponse, ApiOkResponse } from '@nestjs/swagger'; +import { RoomEntity } from './entities/room.entity'; @Controller('room') @ApiTags('room') @@ -18,26 +19,31 @@ export class RoomController { constructor(private readonly roomService: RoomService) {} @Post() + @ApiCreatedResponse({ type: CreateRoomDto }) create(@Body() body: any) { return this.roomService.create(body); } @Get() + @ApiOkResponse({ type: RoomEntity, isArray: true}) findAll() { return this.roomService.findAll(); } @Get(':id') + @ApiOkResponse({ type: RoomEntity }) findOne(@Param('id') id: string) { return this.roomService.findOne(+id); } @Patch(':id') + @ApiOkResponse({ type: RoomEntity }) update(@Param('id') id: string, @Body() updateRoomDto: UpdateRoomDto) { return this.roomService.update(+id, updateRoomDto); } @Delete(':id') + @ApiOkResponse({ type: RoomEntity }) remove(@Param('id') id: string) { return this.roomService.remove(+id); } From 0c6dc9769326963100fda9dde4f22f0c0a9f924d Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 17:05:48 +0900 Subject: [PATCH 08/12] make fmt --- backend/prisma/seed.ts | 1 - backend/src/room/dto/create-room.dto.ts | 2 +- backend/src/room/entities/room.entity.ts | 10 +++++----- backend/src/room/room.controller.ts | 2 +- backend/src/room/room.service.ts | 12 ++++++------ 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/backend/prisma/seed.ts b/backend/prisma/seed.ts index 3743c4ed..843709b0 100644 --- a/backend/prisma/seed.ts +++ b/backend/prisma/seed.ts @@ -71,7 +71,6 @@ async function main() { name: 'Room 2', }, }); - } main() diff --git a/backend/src/room/dto/create-room.dto.ts b/backend/src/room/dto/create-room.dto.ts index 55e2e333..6bdd847f 100644 --- a/backend/src/room/dto/create-room.dto.ts +++ b/backend/src/room/dto/create-room.dto.ts @@ -1,4 +1,4 @@ -import {ApiProperty, ApiPropertyOptional} from '@nestjs/swagger'; +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; export class CreateRoomDto { @ApiProperty() diff --git a/backend/src/room/entities/room.entity.ts b/backend/src/room/entities/room.entity.ts index 009b1cf5..34a76c45 100644 --- a/backend/src/room/entities/room.entity.ts +++ b/backend/src/room/entities/room.entity.ts @@ -1,10 +1,10 @@ import { Room } from '@prisma/client'; -import {ApiProperty} from '@nestjs/swagger'; +import { ApiProperty } from '@nestjs/swagger'; export class RoomEntity implements Room { - @ApiProperty() - id: number; + @ApiProperty() + id: number; - @ApiProperty() - name: string; + @ApiProperty() + name: string; } diff --git a/backend/src/room/room.controller.ts b/backend/src/room/room.controller.ts index 348aaf12..42354f29 100644 --- a/backend/src/room/room.controller.ts +++ b/backend/src/room/room.controller.ts @@ -25,7 +25,7 @@ export class RoomController { } @Get() - @ApiOkResponse({ type: RoomEntity, isArray: true}) + @ApiOkResponse({ type: RoomEntity, isArray: true }) findAll() { return this.roomService.findAll(); } diff --git a/backend/src/room/room.service.ts b/backend/src/room/room.service.ts index 0c0caf04..fe371282 100644 --- a/backend/src/room/room.service.ts +++ b/backend/src/room/room.service.ts @@ -16,17 +16,17 @@ export class RoomService { } findOne(id: number) { - return this.prisma.room.findUniqueOrThrow({ where: { id: id } }); + return this.prisma.room.findUniqueOrThrow({ where: { id: id } }); } update(id: number, updateRoomDto: UpdateRoomDto) { - return this.prisma.room.update({ - where: { id }, - data: updateRoomDto, - }); + return this.prisma.room.update({ + where: { id }, + data: updateRoomDto, + }); } remove(id: number) { - return this.prisma.room.delete({ where: { id }}); + return this.prisma.room.delete({ where: { id } }); } } From eeaf38c2d48cbe351bd357f0c84e5917c6220547 Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 17:38:30 +0900 Subject: [PATCH 09/12] =?UTF-8?q?dto=20=E3=81=AB=20@IsString()=20=E3=82=92?= =?UTF-8?q?=E4=BB=98=E4=B8=8E=E3=81=99=E3=82=8B=E3=81=A8=E3=80=81@Body=20c?= =?UTF-8?q?reateRoomDto:=20=20CreateRoomDto=20=E3=81=A7=E3=82=82=E5=8F=97?= =?UTF-8?q?=E3=81=91=E5=8F=96=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/room/dto/create-room.dto.ts | 4 ++++ backend/src/room/room.controller.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/room/dto/create-room.dto.ts b/backend/src/room/dto/create-room.dto.ts index 6bdd847f..a9a02ca0 100644 --- a/backend/src/room/dto/create-room.dto.ts +++ b/backend/src/room/dto/create-room.dto.ts @@ -1,9 +1,13 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; +import { + IsString, + } from 'class-validator'; export class CreateRoomDto { @ApiProperty() id: number; + @IsString() @ApiProperty() name: string; } diff --git a/backend/src/room/room.controller.ts b/backend/src/room/room.controller.ts index 42354f29..99f15a97 100644 --- a/backend/src/room/room.controller.ts +++ b/backend/src/room/room.controller.ts @@ -20,8 +20,8 @@ export class RoomController { @Post() @ApiCreatedResponse({ type: CreateRoomDto }) - create(@Body() body: any) { - return this.roomService.create(body); + create(@Body() createRoomDto: CreateRoomDto) { + return this.roomService.create(createRoomDto); } @Get() From 847cc36bad1e0bf9d95b1ba0051ba8374342ccc2 Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 17:39:22 +0900 Subject: [PATCH 10/12] fix test add prismaservice room controller and service need PrismaService --- backend/src/room/room.controller.spec.ts | 3 ++- backend/src/room/room.service.spec.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/src/room/room.controller.spec.ts b/backend/src/room/room.controller.spec.ts index 85b65b7e..bc26cadd 100644 --- a/backend/src/room/room.controller.spec.ts +++ b/backend/src/room/room.controller.spec.ts @@ -1,6 +1,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { RoomController } from './room.controller'; import { RoomService } from './room.service'; +import { PrismaService } from 'src/prisma/prisma.service'; describe('RoomController', () => { let controller: RoomController; @@ -8,7 +9,7 @@ describe('RoomController', () => { beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ controllers: [RoomController], - providers: [RoomService], + providers: [RoomService, PrismaService], }).compile(); controller = module.get(RoomController); diff --git a/backend/src/room/room.service.spec.ts b/backend/src/room/room.service.spec.ts index 504502bb..02a69671 100644 --- a/backend/src/room/room.service.spec.ts +++ b/backend/src/room/room.service.spec.ts @@ -1,12 +1,13 @@ import { Test, TestingModule } from '@nestjs/testing'; import { RoomService } from './room.service'; +import { PrismaService } from 'src/prisma/prisma.service'; describe('RoomService', () => { let service: RoomService; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ - providers: [RoomService], + providers: [RoomService, PrismaService], }).compile(); service = module.get(RoomService); From a6c458b5e6aaecc364d3aa9d8dac30bbff514e0c Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 17:39:47 +0900 Subject: [PATCH 11/12] make fmt --- backend/src/room/dto/create-room.dto.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/src/room/dto/create-room.dto.ts b/backend/src/room/dto/create-room.dto.ts index a9a02ca0..71d51261 100644 --- a/backend/src/room/dto/create-room.dto.ts +++ b/backend/src/room/dto/create-room.dto.ts @@ -1,7 +1,5 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { - IsString, - } from 'class-validator'; +import { IsString } from 'class-validator'; export class CreateRoomDto { @ApiProperty() From a7324b59e2fc7f3179447e4bc35b6155190eb7fa Mon Sep 17 00:00:00 2001 From: dorakueYaritai Date: Thu, 9 Nov 2023 17:42:09 +0900 Subject: [PATCH 12/12] lint check --- backend/src/room/dto/create-room.dto.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/room/dto/create-room.dto.ts b/backend/src/room/dto/create-room.dto.ts index 71d51261..854c2236 100644 --- a/backend/src/room/dto/create-room.dto.ts +++ b/backend/src/room/dto/create-room.dto.ts @@ -1,4 +1,4 @@ -import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; +import { ApiProperty } from '@nestjs/swagger'; import { IsString } from 'class-validator'; export class CreateRoomDto {