You can find some nice example in this project. In short typeorm has a really nice method specific to this usecase findAndCount.
async findAll(query): Promise<Paginate> {
const take = query.take || 10
const skip = query.skip || 0
const keyword = query.keyword || ''
const [result, total] = await this.userRepository.findAndCount(
{
where: { name: Like('%' + keyword + '%') }, order: { name: "DESC" },
take: take,
skip: skip
}
);
return {
data: result,
count: total
}
}