Feat: Return client id of newly created client (#2190)

return client id of newly created client
This commit is contained in:
Bernd Storath
2025-09-29 08:20:00 +02:00
committed by GitHub
parent 7b2d234ea5
commit cbbf5d3d25
2 changed files with 6 additions and 3 deletions
+4 -2
View File
@@ -9,8 +9,10 @@ export default definePermissionEventHandler(
validateZod(ClientCreateSchema, event)
);
await Database.clients.create({ name, expiresAt });
const result = await Database.clients.create({ name, expiresAt });
await WireGuard.saveConfig();
return { success: true };
const clientId = result[0]!.clientId;
return { success: true, clientId };
}
);
@@ -132,7 +132,7 @@ export class ClientService {
const ipv6Cidr = parseCidr(clientInterface.ipv6Cidr);
const ipv6Address = nextIP(6, ipv6Cidr, clients);
await tx
return await tx
.insert(client)
.values({
name,
@@ -150,6 +150,7 @@ export class ClientService {
serverAllowedIps: [],
enabled: true,
})
.returning({ clientId: client.id })
.execute();
});
}