Skip to content

Commit f3678a8

Browse files
committed
refactor: simplify product controller routes by using base controller path
1 parent 3f746e6 commit f3678a8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/product/product.controller.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,50 @@ import { CreateProductDto } from './dto/create-product.dto';
44
import { UpdateProductDto } from './dto/update-product.dto';
55
import { Product } from './entities/product.entity';
66

7-
@Controller()
7+
@Controller("products")
88
export class ProductController {
9-
constructor(private readonly productService: ProductService) {}
9+
constructor(private readonly productService: ProductService) { }
1010

1111
// Admin endpoints
12-
@Post('admin/products')
12+
@Post('admin')
1313
create(@Body() createProductDto: CreateProductDto) {
1414
return this.productService.create(createProductDto);
1515
}
1616

17-
@Get('admin/products')
17+
@Get('admin')
1818
findAll(
1919
@Query('page') page?: number,
2020
@Query('limit') limit?: number,
2121
) {
2222
return this.productService.findAll(page, limit);
2323
}
2424

25-
@Get('admin/products/:id')
25+
@Get('admin/:id')
2626
findOne(@Param('id') id: string) {
2727
return this.productService.findOne(+id);
2828
}
2929

30-
@Patch('admin/products/:id')
30+
@Patch('admin/:id')
3131
update(@Param('id') id: string, @Body() updateProductDto: UpdateProductDto) {
3232
return this.productService.update(+id, updateProductDto);
3333
}
3434

35-
@Delete('admin/products/:id')
35+
@Delete('admin/:id')
3636
@HttpCode(HttpStatus.NO_CONTENT)
3737
async remove(@Param('id') id: string) {
3838
await this.productService.remove(+id);
3939
}
4040

4141
// Public endpoints
42-
@Get('products')
42+
@Get('')
4343
findAllActive(
4444
@Query('page') page?: number,
4545
@Query('limit') limit?: number,
4646
) {
4747
return this.productService.findAllActive(page, limit);
4848
}
4949

50-
@Get('products/:id')
50+
@Get(':id')
5151
findOnePublic(@Param('id') id: string) {
5252
return this.productService.findOne(+id);
5353
}

0 commit comments

Comments
 (0)