import { Controller, Get, Patch, Query, Body } from '@nestjs/common';
import { BlocksService } from './blocks.service';

@Controller('blocks')
export class BlocksController {
  constructor(private blocks: BlocksService) {}

  @Get()
  findAll() {
    return this.blocks.findAll();
  }

  @Get('by-path')
  findByPath(@Query('path') path: string) {
    return this.blocks.findByPath(path);
  }

  @Patch('by-path')
  update(
    @Query('path') path: string,
    @Body() body: { version?: string; isInPreview?: boolean; changelog?: object[] },
  ) {
    return this.blocks.update(path, body);
  }
}
