feat: Implement api/v1/users API endpoint

This commit is contained in:
Faruk AYDIN
2024-02-14 00:52:17 +01:00
parent b89a4d58d9
commit da732becb6
2 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { renderObject } from '../../../../helpers/renderer.js';
import User from '../../../../models/user.js';
import paginateRest from '../../../../helpers/pagination-rest.js';
export default async (request, response) => {
const usersQuery = User.query()
.leftJoinRelated({
role: true,
})
.withGraphFetched({
role: true,
})
.orderBy('full_name', 'asc');
const users = await paginateRest(usersQuery, request.query.page);
renderObject(response, users);
};