Files
calendar/packages/trpc/server/routers/viewer/attributes/list.handler.ts
T
devin-ai-integration[bot]GitHubbenny@cal.com <benny@cal.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>benny@cal.com <benny@cal.com>hbjORbj
e115095198 perf: migrate listHandler to AttributeRepository + cache attributes fetching in RSCs (#21552)
* refactor: migrate listHandler to AttributeRepository

Co-Authored-By: benny@cal.com <benny@cal.com>

* cache attributes list

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: benny@cal.com <benny@cal.com>
Co-authored-by: hbjORbj <sldisek783@gmail.com>
2025-05-29 15:01:44 -04:00

27 lines
625 B
TypeScript

import { AttributeRepository } from "@calcom/lib/server/repository/attribute";
import { TRPCError } from "@trpc/server";
import type { TrpcSessionUser } from "../../../types";
type GetOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
};
};
const listHandler = async (opts: GetOptions) => {
const org = opts.ctx.user.organization;
if (!org.id) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: "You need to be apart of an organization to use this feature",
});
}
return await AttributeRepository.findAllByOrgIdWithOptions({ orgId: org.id });
};
export default listHandler;