Allow picking ips when creating stuff

This commit is contained in:
Owen
2025-04-18 14:41:27 -04:00
parent d664aa204f
commit 581fdd67b1
9 changed files with 212 additions and 156 deletions

View File

@@ -71,7 +71,7 @@ export async function createOrg(
const { orgId, name, subnet } = parsedBody.data;
if (subnet && !isValidCIDR(subnet)) {
if (!isValidCIDR(subnet)) {
return next(
createHttpError(
HttpCode.BAD_REQUEST,
@@ -80,6 +80,22 @@ export async function createOrg(
);
}
// make sure the subnet is unique
const subnetExists = await db
.select()
.from(orgs)
.where(eq(orgs.subnet, subnet))
.limit(1);
if (subnetExists.length > 0) {
return next(
createHttpError(
HttpCode.CONFLICT,
`Subnet ${subnet} already exists`
)
);
}
// make sure the orgId is unique
const orgExists = await db
.select()