changed contacts routes to typescript

This commit is contained in:
canove
2020-09-15 19:28:06 -03:00
parent 14d90a2dd4
commit b04c0b878e
21 changed files with 536 additions and 133 deletions

View File

@@ -3,7 +3,7 @@ import User from "../../models/User";
interface Request {
searchParam?: string;
pageNumber?: number;
pageNumber?: string;
}
interface Response {
@@ -14,7 +14,7 @@ interface Response {
const ListUsersService = async ({
searchParam = "",
pageNumber = 1
pageNumber = "1"
}: Request): Promise<Response> => {
const whereCondition = {
[Op.or]: [
@@ -28,8 +28,8 @@ const ListUsersService = async ({
{ email: { [Op.like]: `%${searchParam.toLowerCase()}%` } }
]
};
const limit = 20;
const offset = limit * (pageNumber - 1);
const limit = 10;
const offset = limit * (+pageNumber - 1);
const { count, rows: users } = await User.findAndCountAll({
where: whereCondition,
@@ -39,7 +39,7 @@ const ListUsersService = async ({
order: [["createdAt", "DESC"]]
});
const hasMore = count > limit + users.length;
const hasMore = count > offset + users.length;
return {
users,