finished, functional API

This commit is contained in:
Tzvetan Trave
2025-10-02 16:04:50 +02:00
parent 22da9af53d
commit 439e5a0acf
18 changed files with 368 additions and 322 deletions

16
src/api/user/gUsers.js Normal file
View File

@ -0,0 +1,16 @@
export async function gUsers(request, reply, fastify, getUserData) {
try {
const { iStart, iEnd } = request.query;
if (Number(iEnd) < Number(iStart)) {
return reply.code(400).send({ error: "Starting index cannot be strictly inferior to ending index" });
}
const users = getUserData.all(Number(iEnd) - Number(iStart), Number(iStart));
if (!users.length) {
return reply.code(404).send({ error: "No users exist in the selected range" });
}
return reply.code(200).send({ users });
} catch (err) {
fastify.log.error(err);
return reply.code(500).send({ error: "Internal server error" });
}
}