upd
This commit is contained in:
@@ -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
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ async function getClients({
|
||||
manager: { columns: { password: false } },
|
||||
app: true,
|
||||
comments: { with: { manager: { columns: { password: false } } } },
|
||||
server: true,
|
||||
client: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -50,7 +50,6 @@ async function getSessions(
|
||||
manager: {
|
||||
columns: {
|
||||
password: false,
|
||||
fullname: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user