Skip to content

Commit b751f00

Browse files
committed
fix bug slug
1 parent 1eed969 commit b751f00

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

apps/api/src/app.controller.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,8 @@ export class AppController {
126126
const { path, slug } = params;
127127
return this.roomService.send({ cmd: 'get-room-by-slug' }, { path, slug });
128128
}
129+
@Get('room-types/all')
130+
async getAllRoomTypes() {
131+
return this.roomService.send({ cmd: 'get-all-room-types' }, {});
132+
}
129133
}

apps/api/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ValidationPipe } from '@nestjs/common';
55
async function bootstrap() {
66
const app = await NestFactory.create(AppModule);
77
app.useGlobalPipes(new ValidationPipe());
8+
app.enableCors();
89
await app.listen(3000);
910
}
1011
bootstrap();

apps/room/src/room.controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,9 @@ export class RoomController {
7676
this.sharedService.acknowledgeMessage(context);
7777
return this.roomService.getRoomBySlug(payload.path, payload.slug);
7878
}
79+
@MessagePattern({ cmd: 'get-all-room-types' })
80+
async getAllRoomTypes(@Ctx() context: RmqContext) {
81+
this.sharedService.acknowledgeMessage(context);
82+
return this.roomService.getAllRoomTypes();
83+
}
7984
}

apps/room/src/room.service.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,16 @@ export class RoomService {
195195
return e;
196196
}
197197
}
198+
async getAllRoomTypes() {
199+
try {
200+
const data = await this.RoomTypeRepository.findAllWithPopulate({});
201+
if (!data) {
202+
throw new HttpException('No room type found', HttpStatus.NOT_FOUND);
203+
}
204+
return data;
205+
} catch (e) {
206+
if (e instanceof HttpException) return e;
207+
return e;
208+
}
209+
}
198210
}

0 commit comments

Comments
 (0)