Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
@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,
) {
* 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));
}
}
},
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()
},
},
})
@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);
}
}
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);
}
}
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));
}
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);
}
}
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 };
}
}
* 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));
}
}