How to use the @nestjsx/crud.Override function in @nestjsx/crud

To help you get started, we’ve selected a few @nestjsx/crud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nestjsx / crud / integration / typeorm / src / companies / companies.controller.ts View on Github external
})
@ApiUseTags('companies')
@Controller('companies')
export class CompaniesController {
  constructor(public service: CompaniesService) {}

  get base(): CrudController {
    return this;
  }

  @Override()
  async getOne(@ParsedQuery() query, @ParsedOptions() options) {
    return this.base.getOneBase(query, options);
  }

  @Override()
  async createOne(@ParsedParams() params, @ParsedBody() body: Company) {
    return this.base.createOneBase(params, body);
  }

  @Override()
  async createMany(@ParsedParams() params, @ParsedBody() body: EntitiesBulk) {
    return this.base.createManyBase(params, body);
  }

  @Get('/custom/get-all')
  @UsePathInterceptors()
  async customRoute(
    @ParsedQuery() query: RestfulParamsDto,
    @ParsedParams() params,
    @ParsedOptions() options: CrudOptions,
  ) {
github oracle-quickstart / oci-cloudnative / src / user / src / services / user / user.controller.ts View on Github external
* User creation / (registration)
   * @param req
   * @param dto
   */
  @Override()
  createOne(@ParsedRequest() req: CrudRequest, @ParsedBody() dto: User) {
    return this.base.createOneBase(req, User.hashPassword(dto))
      .then(user => this.service.filterDTO(user));
  }

  /**
   * Custom PATCH /:id
   * @param req
   * @param dto
   */
  @Override()
  updateOne(@ParsedRequest() req: CrudRequest, @ParsedBody() dto: User) {
    return this.base.updateOneBase(req, User.hashPassword(dto))
      .then(user => this.service.filterDTO(user));
  }

  /**
   * Custom PUT /:id
   * @param req
   * @param dto
   */
  @Override()
  replaceOne(@ParsedRequest() req: CrudRequest, @ParsedBody() dto: User) {
    return this.base.replaceOneBase(req, User.hashPassword(dto))
      .then(user => this.service.filterDTO(user));
  }
}
github nestjsx / crud / integration / typeorm / src / companies / companies.controller.ts View on Github external
},
    sort: [{ field: 'id', order: 'DESC' }],
    maxLimit: 5,
    cache: 10000,
  },
})
@ApiUseTags('companies')
@Controller('companies')
export class CompaniesController {
  constructor(public service: CompaniesService) {}

  get base(): CrudController {
    return this;
  }

  @Override()
  async getOne(@ParsedQuery() query, @ParsedOptions() options) {
    return this.base.getOneBase(query, options);
  }

  @Override()
  async createOne(@ParsedParams() params, @ParsedBody() body: Company) {
    return this.base.createOneBase(params, body);
  }

  @Override()
  async createMany(@ParsedParams() params, @ParsedBody() body: EntitiesBulk) {
    return this.base.createManyBase(params, body);
  }

  @Get('/custom/get-all')
  @UsePathInterceptors()
github oracle-quickstart / oci-cloudnative / src / user / src / services / user / user.cards.controller.ts View on Github external
},
  },
})
@Controller(`/${ROUTE.USERS}/:userId/${ROUTE.CARDS}`)
export class UserCardsController extends BaseCardsController {

  constructor(public service: CardService) {
    super(service);
  }

  /**
   * Card creation
   * @param req
   * @param dto
   */
  @Override()
  createOne(@ParsedRequest() req: CrudRequest, @ParsedBody() dto: UserCard) {
    return super.createOne(req, dto);
  }
}
github oracle-quickstart / oci-cloudnative / src / user / src / services / user / card / card.controller.ts View on Github external
type: UserCard,
  },
})
@Controller(ROUTE.CARDS)
export class CardsController extends BaseCardsController {

  constructor(public service: CardService) {
    super(service);
  }

  /**
   * Card creation
   * @param req
   * @param dto
   */
  @Override()
  createOne(@ParsedRequest() req: CrudRequest, @ParsedBody() dto: UserCard) {
    return super.createOne(req, dto);
  }
}
github oracle-quickstart / oci-cloudnative / src / user / src / services / user / user.controller.ts View on Github external
export class UsersController implements CrudController {
  constructor(public service: UserService) {}

  /**
   * get typed base class
   */
  get base(): CrudController {
    return this;
  }

  /**
   * User creation / (registration)
   * @param req
   * @param dto
   */
  @Override()
  createOne(@ParsedRequest() req: CrudRequest, @ParsedBody() dto: User) {
    return this.base.createOneBase(req, User.hashPassword(dto))
      .then(user => this.service.filterDTO(user));
  }

  /**
   * Custom PATCH /:id
   * @param req
   * @param dto
   */
  @Override()
  updateOne(@ParsedRequest() req: CrudRequest, @ParsedBody() dto: User) {
    return this.base.updateOneBase(req, User.hashPassword(dto))
      .then(user => this.service.filterDTO(user));
  }
github nestjsx / crud / integration / crud-typeorm / users / users.controller.ts View on Github external
eager: true,
        exclude: ['updatedAt'],
      },
    },
  },
})
@ApiTags('users')
@Controller('/companies/:companyId/users')
export class UsersController implements CrudController {
  constructor(public service: UsersService) {}

  get base(): CrudController {
    return this;
  }

  @Override('getManyBase')
  getAll(@ParsedRequest() req: CrudRequest) {
    return this.base.getManyBase(req);
  }
}
github nestjsx / crud / integration / typeorm / src / companies / companies.controller.ts View on Github external
get base(): CrudController {
    return this;
  }

  @Override()
  async getOne(@ParsedQuery() query, @ParsedOptions() options) {
    return this.base.getOneBase(query, options);
  }

  @Override()
  async createOne(@ParsedParams() params, @ParsedBody() body: Company) {
    return this.base.createOneBase(params, body);
  }

  @Override()
  async createMany(@ParsedParams() params, @ParsedBody() body: EntitiesBulk) {
    return this.base.createManyBase(params, body);
  }

  @Get('/custom/get-all')
  @UsePathInterceptors()
  async customRoute(
    @ParsedQuery() query: RestfulParamsDto,
    @ParsedParams() params,
    @ParsedOptions() options: CrudOptions,
  ) {
    return { query, params, options };
  }
}
github oracle-quickstart / oci-cloudnative / src / user / src / services / user / user.controller.ts View on Github external
* Custom PATCH /:id
   * @param req
   * @param dto
   */
  @Override()
  updateOne(@ParsedRequest() req: CrudRequest, @ParsedBody() dto: User) {
    return this.base.updateOneBase(req, User.hashPassword(dto))
      .then(user => this.service.filterDTO(user));
  }

  /**
   * Custom PUT /:id
   * @param req
   * @param dto
   */
  @Override()
  replaceOne(@ParsedRequest() req: CrudRequest, @ParsedBody() dto: User) {
    return this.base.replaceOneBase(req, User.hashPassword(dto))
      .then(user => this.service.filterDTO(user));
  }
}