Created some user endpoints ; Pretty code

This commit is contained in:
Kevin Puig
2025-09-27 11:13:37 -04:00
parent 122cfdd8c3
commit b22734831e
12 changed files with 240 additions and 240 deletions

View File

@@ -0,0 +1,25 @@
import { Hono } from "hono";
import { fetchAllUsers, fetchUserData } from "../controller/userController";
const actions = new Hono();
actions.get("user/:id", async (c) => {
const id = c.req.param("id");
const userData = await fetchUserData(id);
if (userData) {
return c.json(userData);
} else {
return c.json({ error: "User not found" }, 404);
}
});
actions.get("instance/:id/users", async (c) => {
const instanceId = c.req.param("id");
const userData = await fetchAllUsers(instanceId);
if (userData) {
return c.json(userData);
} else {
return c.json({ error: "Error getting all users from instance" }, 500);
}
});
export default actions;