logbook view entry (#28)

This commit was merged in pull request #28.
This commit is contained in:
2024-11-18 13:49:45 +00:00
committed by GitHub
parent 52b29163e6
commit 014aef31aa
8 changed files with 249 additions and 88 deletions

View File

@@ -1,4 +1,11 @@
import { Body, Controller, Get, HttpException, Post } from '@nestjs/common';
import {
Body,
Controller,
Get,
HttpException,
Param,
Post
} from '@nestjs/common';
import { LogbookService } from './logbook.service';
import { LogbookDto } from './logbook.dto';
import { CustomError } from '../customError/CustomError';
@@ -9,6 +16,24 @@ import { LogbookEntity } from './logbook.entity';
export class LogbookController {
constructor(private readonly logbookService: LogbookService) {}
@Get(':entryId')
async find(@Param() params: any): Promise<LogbookEntity> {
console.log(params);
try {
const entry: LogbookEntity = await this.logbookService.find(
params.entryId
);
return entry;
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode, {
cause: customError.name
});
}
}
@Get()
async findAll(): Promise<LogbookEntity[]> {
try {