@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user