upd
This commit is contained in:
@@ -4,6 +4,7 @@ import createClient from "../services/clients/createClient";
|
|||||||
import getByPhone from "../services/clients/getByPhone";
|
import getByPhone from "../services/clients/getByPhone";
|
||||||
import getClients from "../services/clients/getClients";
|
import getClients from "../services/clients/getClients";
|
||||||
import getCount from "../services/clients/getCount";
|
import getCount from "../services/clients/getCount";
|
||||||
|
import { editClient } from "../services/clients/editClient";
|
||||||
|
|
||||||
export const clientsController = new Elysia({ prefix: "/clients" })
|
export const clientsController = new Elysia({ prefix: "/clients" })
|
||||||
.use(authMiddleware)
|
.use(authMiddleware)
|
||||||
@@ -31,4 +32,16 @@ export const clientsController = new Elysia({ prefix: "/clients" })
|
|||||||
phone: t.String(),
|
phone: t.String(),
|
||||||
email: t.Nullable(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(commentsController);
|
||||||
app.use(filesController);
|
app.use(filesController);
|
||||||
|
|
||||||
app.use(swagger()).listen(3000);
|
app
|
||||||
|
.use(swagger({ swaggerOptions: { persistAuthorization: true } }))
|
||||||
|
.listen(3000);
|
||||||
|
|
||||||
async function checkServersStatus() {
|
async function checkServersStatus() {
|
||||||
const servers = await db.query.serversTable.findMany();
|
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 } },
|
manager: { columns: { password: false } },
|
||||||
app: true,
|
app: true,
|
||||||
comments: { with: { manager: { columns: { password: false } } } },
|
comments: { with: { manager: { columns: { password: false } } } },
|
||||||
|
server: true,
|
||||||
|
client: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ async function getSessions(
|
|||||||
manager: {
|
manager: {
|
||||||
columns: {
|
columns: {
|
||||||
password: false,
|
password: false,
|
||||||
fullname: true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user