(
input: z.infer<typeof zServerCreate> & {
id: string;
name: string;
},
)
| 49 | } |
| 50 | |
| 51 | export async function createServer( |
| 52 | input: z.infer<typeof zServerCreate> & { |
| 53 | id: string; |
| 54 | name: string; |
| 55 | }, |
| 56 | ) { |
| 57 | // Explicitly type this to avoid passing into .parse missing information |
| 58 | const combinedCreateData = await applyServerSettingsSideEffects({ |
| 59 | old: getDefaultServerWithFlags(input), |
| 60 | updated: input, |
| 61 | }); |
| 62 | await db.insert(dbServers).values(zServerCreate.parse(combinedCreateData)); |
| 63 | const created = await db.query.dbServers.findFirst({ |
| 64 | where: eq(dbServers.id, input.id), |
| 65 | }); |
| 66 | if (!created) throw new Error(`Error creating server with id ${input.id}`); |
| 67 | return addFlagsToServer(created); |
| 68 | } |
| 69 | |
| 70 | export async function findAllServers(opts?: { |
| 71 | includeKicked: boolean; |
no test coverage detected