Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Controller, UseGuards } from '@nestjs/common';
- import { Crud, CrudAuth, CrudController } from '@nestjsx/crud';
- import { JwtAuthGuard } from '../auth/jwt-auth.guard';
- import { Project } from './projects.entity';
- import { ProjectsService } from './projects.service';
- @UseGuards(JwtAuthGuard)
- @Crud({
- model: {
- type: Project,
- },
- params: {
- id: {
- field: 'id',
- type: 'uuid',
- primary: true,
- },
- },
- query: {
- join: {
- user: {
- eager: true,
- },
- },
- },
- })
- @CrudAuth({
- property: 'user',
- filter: (user) => ({ 'user.id': user.id }),
- persist: (user) => ({ userId: user.id }),
- })
- @Controller('projects')
- export class ProjectsController implements CrudController<Project> {
- constructor(public service: ProjectsService) {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement