Fix: Allow query function to be called with undefined orgId, and handle it as an error

This commit is contained in:
Daniel Hougaard
2024-03-25 21:43:08 +01:00
parent b23deca8e4
commit f7122c21fd

View File

@@ -168,8 +168,12 @@ export const projectDALFactory = (db: TDbClient) => {
}
};
const findProjectBySlug = async (slug: string, orgId: string) => {
const findProjectBySlug = async (slug: string, orgId: string | undefined) => {
try {
if (!orgId) {
throw new BadRequestError({ message: "Organization ID is required when querying with slugs" });
}
const projects = await db(TableName.ProjectMembership)
.where(`${TableName.Project}.slug`, slug)
.where(`${TableName.Project}.orgId`, orgId)