MCPcopy Index your code
hub / github.com/AnswerOverflow/AnswerOverflow / updateServer

Function updateServer

packages/core/src/server.ts:84–112  ·  view source on GitHub ↗
({
	update,
	existing,
}: {
	update: z.infer<typeof zServerUpdate>;
	existing: Server | null;
})

Source from the content-addressed store, hash-verified

82}
83
84export async function updateServer({
85 update,
86 existing,
87}: {
88 update: z.infer<typeof zServerUpdate>;
89 existing: Server | null;
90}) {
91 if (!existing) {
92 existing = await findServerById(update.id);
93 if (!existing) throw new Error(`Server with id ${update.id} not found`);
94 }
95 // Explicitly type this to avoid passing into .parse missing information
96 const combinedUpdateData = await applyServerSettingsSideEffects({
97 old: existing,
98 updated: update,
99 });
100
101 await db
102 .update(dbServers)
103 .set(zServerUpdate.parse(combinedUpdateData))
104 .where(eq(dbServers.id, update.id));
105
106 const updated = await db.query.dbServers.findFirst({
107 where: eq(dbServers.id, update.id),
108 });
109
110 if (!updated) throw new Error(`Error updating server with id ${update.id}`);
111 return addFlagsToServer(updated);
112}
113
114export async function findServerById(id: string) {
115 const found = await db.query.dbServers.findFirst({

Callers 7

server.test.tsFile · 0.90
dashboard.tsFile · 0.90
server.tsFile · 0.90
operationFunction · 0.90
runMethod · 0.90
webhookHandlerFunction · 0.90
upsertServerFunction · 0.85

Calls 4

addFlagsToServerFunction · 0.90
findServerByIdFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected