[FEATURE] Very basic server updates

This commit is contained in:
Dunemask 2024-01-22 11:04:19 -07:00
parent 23efaafe1d
commit eb53e56dc7
16 changed files with 255 additions and 14 deletions

View file

@ -1,5 +1,10 @@
import pg from "../postgres.js";
import { deleteQuery, insertQuery, selectWhereQuery } from "../pg-query.js";
import {
deleteQuery,
insertQuery,
selectWhereQuery,
updateWhereAllQuery,
} from "../pg-query.js";
import ExpressClientError from "../../util/ExpressClientError.js";
const table = "servers";
@ -128,6 +133,45 @@ export async function getServerEntry(serverId) {
}
}
export async function modifyServerEntry(serverSpec) {
const {
id,
name,
host,
version,
serverType: server_type,
memory,
extraPorts: extra_ports,
backupEnabled: backup_enabled,
backupHost: backup_host,
backupBucket: backup_bucket_path,
backupId: backup_id,
backupKey: backup_key,
backupInterval: backup_interval,
} = serverSpec;
const q = updateWhereAllQuery(
table,
{
name,
host,
version,
server_type,
memory,
extra_ports,
backup_enabled,
backup_host,
backup_bucket_path,
backup_id,
backup_key,
backup_interval,
},
{ id },
);
return pg.query(q);
}
export async function getServerEntries() {
const q = `SELECT * FROM ${table}`;
return pg.query(q);