Setup fetch and wip fetchall route for getting companies.
This commit is contained in:
@@ -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);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user