Setup fetch and wip fetchall route for getting companies.

This commit is contained in:
2026-01-26 18:14:28 -06:00
parent 7748e6171b
commit 24d0c066fd
6 changed files with 163 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import { prisma } from "../constants";
import { CompanyController } from "../controllers/CompanyController";
export const companies = {
async fetch(identifier: string | number): Promise<CompanyController> {
const search = await prisma.company.findFirst({
where: {
OR: [
{ id: identifier as string },
{ cw_CompanyId: identifier as number },
{ cw_Identifier: identifier as string },
],
},
});
if (!search) throw new Error("Unknown company.");
return new CompanyController(search);
},
};