This commit is contained in:
2025-06-04 12:34:54 +05:00
parent 63518f36a1
commit 3341eb63e5
4 changed files with 57 additions and 1 deletions
+1
View File
@@ -14,6 +14,7 @@ export default async function getServers(
try {
const servers = await db.query.serversTable.findMany({
where: eq(serversTable.companyId, auth.companyId),
orderBy: desc(serversTable.createdAt),
with: {
...(query?.with
? Object.fromEntries(
+35
View File
@@ -0,0 +1,35 @@
import { error } from "elysia";
import { eq } from "drizzle-orm";
import db from "../../db";
import { serversTable } from "../../db/schema/servers";
async function updateServer({
params,
body,
}: {
body: {
name: string;
location: string;
};
params: {
id: string;
};
}) {
try {
return (
await db
.update(serversTable)
.set({
name: body.name,
location: body.location,
})
.where(eq(serversTable.id, params.id))
.returning()
)[0];
} catch (err) {
console.log((err as Error).message);
return error(500, "Internal Server Error");
}
}
export default updateServer;
+6
View File
@@ -20,6 +20,12 @@ async function getSessions(
client: true,
app: true,
server: true,
owner: {
columns: {
password: false,
fullname: true,
},
},
},
limit: query?.limit,
orderBy: desc(sessionsTable.createdAt),