49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
HttpCode,
|
|
Param,
|
|
ParseUUIDPipe,
|
|
Put,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { CurrentPrincipal } from '../identity/access.decorator';
|
|
import type { Principal } from '../identity/identity.types';
|
|
import type { PageInput } from '../identity/identity.schemas';
|
|
import { SchemaPipe } from '../common/validation.pipe';
|
|
import { WishlistStore } from './wishlist.store';
|
|
import { wishlistQuerySchema, wishlistSaveSchema } from './wishlist.schemas';
|
|
|
|
@Controller('wishlist')
|
|
export class WishlistController {
|
|
constructor(private readonly wishlist: WishlistStore) {}
|
|
|
|
@Get()
|
|
list(
|
|
@CurrentPrincipal() actor: Principal,
|
|
@Query(new SchemaPipe(wishlistQuerySchema)) query: PageInput,
|
|
) {
|
|
return this.wishlist.list(actor, query);
|
|
}
|
|
|
|
@Put(':variantId')
|
|
save(
|
|
@CurrentPrincipal() actor: Principal,
|
|
@Param('variantId', ParseUUIDPipe) variantId: string,
|
|
@Body(new SchemaPipe(wishlistSaveSchema)) _input: Record<string, never>,
|
|
) {
|
|
return this.wishlist.save(actor, variantId);
|
|
}
|
|
|
|
@Delete(':variantId')
|
|
@HttpCode(204)
|
|
remove(
|
|
@CurrentPrincipal() actor: Principal,
|
|
@Param('variantId', ParseUUIDPipe) variantId: string,
|
|
) {
|
|
return this.wishlist.remove(actor, variantId);
|
|
}
|
|
}
|