Fix bugs and change makefile

This commit is contained in:
Owen Schwartz
2024-10-20 12:55:28 -04:00
parent 16e2a262e9
commit 002614499b
13 changed files with 150 additions and 159 deletions

View File

@@ -37,7 +37,6 @@ export async function listRoleSites(req: Request, res: Response, next: NextFunct
.select({
siteId: sites.siteId,
name: sites.name,
subdomain: sites.subdomain,
})
.from(roleSites)
.innerJoin(sites, eq(roleSites.siteId, sites.siteId))

View File

@@ -10,7 +10,7 @@ import { ActionsEnum, checkUserActionPermission } from '@server/auth/actions';
import logger from '@server/logger';
const listRolesParamsSchema = z.object({
orgId: z.string().optional().transform(Number).pipe(z.number().int().positive()),
orgId: z.string()
});
const listRolesSchema = z.object({
@@ -61,14 +61,11 @@ export async function listRoles(req: Request, res: Response, next: NextFunction)
orgName: orgs.name,
})
.from(roles)
.leftJoin(orgs, eq(roles.orgId, orgs.orgId));
.leftJoin(orgs, eq(roles.orgId, orgs.orgId))
.where(eq(roles.orgId, orgId));
let countQuery: any = db.select({ count: sql<number>`cast(count(*) as integer)` }).from(roles);
if (orgId) {
baseQuery = baseQuery.where(eq(roles.orgId, orgId));
countQuery = countQuery.where(eq(roles.orgId, orgId));
}
let countQuery: any = db.select({ count: sql<number>`cast(count(*) as integer)` }).from(roles)
.where(eq(roles.orgId, orgId));
const rolesList = await baseQuery.limit(limit).offset(offset);
const totalCountResult = await countQuery;

View File

@@ -25,7 +25,7 @@ const createSiteSchema = z.object({
subnet: z.string().optional(),
});
export type GetSiteResponse = {
export type CreateSiteResponse = {
name: string;
siteId: number;
orgId: string;

View File

@@ -11,7 +11,7 @@ import { eq } from 'drizzle-orm';
const addUserSiteSchema = z.object({
userId: z.string(),
siteId: z.string().optional().transform(stoi).pipe(z.number().int().positive().optional()),
siteId: z.string().transform(Number).pipe(z.number().int().positive()),
});
export async function addUserSite(req: Request, res: Response, next: NextFunction): Promise<any> {