This commit is contained in:
2025-06-19 18:36:31 +05:00
parent 971cd8ff8e
commit cd61fc686b
5 changed files with 43 additions and 3 deletions
+14 -1
View File
@@ -4,6 +4,7 @@ import createClient from "../services/clients/createClient";
import getByPhone from "../services/clients/getByPhone";
import getClients from "../services/clients/getClients";
import getCount from "../services/clients/getCount";
import { editClient } from "../services/clients/editClient";
export const clientsController = new Elysia({ prefix: "/clients" })
.use(authMiddleware)
@@ -31,4 +32,16 @@ export const clientsController = new Elysia({ prefix: "/clients" })
phone: t.String(),
email: t.Nullable(t.String()),
}),
});
})
.put(
"/:clientId",
async ({ body, params: { clientId } }) => editClient(clientId, body),
{
params: t.Object({ clientId: t.String() }),
body: t.Object({
name: t.String(),
phone: t.String(),
email: t.Nullable(t.String()),
}),
}
);
+3 -1
View File
@@ -31,7 +31,9 @@ app.use(clientsController);
app.use(commentsController);
app.use(filesController);
app.use(swagger()).listen(3000);
app
.use(swagger({ swaggerOptions: { persistAuthorization: true } }))
.listen(3000);
async function checkServersStatus() {
const servers = await db.query.serversTable.findMany();
+24
View File
@@ -0,0 +1,24 @@
import db from "../../db";
import { clientsTable } from "../../db/schema";
import { eq } from "drizzle-orm";
import { status } from "elysia";
export async function editClient(
clientId: string,
data: {
email: string | null;
phone: string;
name: string;
}
) {
try {
return await db
.update(clientsTable)
.set(data)
.where(eq(clientsTable.id, clientId))
.returning();
} catch (error) {
console.log(error);
return status(500, "Internal Server Error");
}
}
+2
View File
@@ -32,6 +32,8 @@ async function getClients({
manager: { columns: { password: false } },
app: true,
comments: { with: { manager: { columns: { password: false } } } },
server: true,
client: true,
},
},
},
-1
View File
@@ -50,7 +50,6 @@ async function getSessions(
manager: {
columns: {
password: false,
fullname: true,
},
},
},