48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
Post,
|
|
Put,
|
|
Req,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { AuthGuard } from 'src/core/guards/auth.guard';
|
|
import { CylinderService } from './cylinder.service';
|
|
import { AuthenticatedRequest } from 'src/model/interface/authenticated-request.interface';
|
|
import { Cylinder } from 'src/model/entitites';
|
|
|
|
@UseGuards(AuthGuard)
|
|
@Controller('cylinder')
|
|
export class CylinderController {
|
|
constructor(private service: CylinderService) {}
|
|
|
|
@Get()
|
|
getCylinders(@Req() req: AuthenticatedRequest): Promise<Cylinder[]> {
|
|
return this.service.getCylinders(req.user);
|
|
}
|
|
|
|
@Delete(':id')
|
|
deleteKey(@Req() req: AuthenticatedRequest, @Param('id') id: string) {
|
|
return this.service.deleteCylinder(req.user, id);
|
|
}
|
|
|
|
@Put()
|
|
updateCylinder(
|
|
@Req() req: AuthenticatedRequest,
|
|
@Body() b: Partial<Cylinder>,
|
|
) {
|
|
return this.service.updateCylinder(req.user, b);
|
|
}
|
|
|
|
@Post()
|
|
createCylinder(
|
|
@Req() req: AuthenticatedRequest,
|
|
@Body() b: Partial<Cylinder>,
|
|
) {
|
|
return this.service.createCylinder(req.user, b);
|
|
}
|
|
}
|