Files
calendar/packages/features/di/modules/OrgMembershipLookup.ts
T
3e7e376100 chore: Some minor fixes and follow up to #26446 (#26587)
* init

* DI and other improvements

* type fix

---------

Co-authored-by: Volnei Munhoz <volnei@cal.com>
2026-01-12 04:32:55 +00:00

20 lines
868 B
TypeScript

import { ProfileRepository } from "@calcom/features/profile/repositories/ProfileRepository";
import type { OrgMembershipLookup } from "@calcom/trpc/server/routers/viewer/slots/util";
import { createModule, type Module } from "../di";
import { DI_TOKENS } from "../tokens";
/**
* Adapter that wraps ProfileRepository's static method to satisfy the OrgMembershipLookup interface.
* This lives in the composition root where implementation details are wired together.
*/
const orgMembershipLookupAdapter: OrgMembershipLookup = {
findFirstOrganizationIdForUser: ({ userId }: { userId: number }) =>
ProfileRepository.findFirstOrganizationIdForUser({ userId }),
};
const orgMembershipLookupModule: Module = createModule();
orgMembershipLookupModule.bind(DI_TOKENS.ORG_MEMBERSHIP_LOOKUP).toValue(orgMembershipLookupAdapter);
export { orgMembershipLookupModule };