mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* trpc procedures an middleware refactor * allow use sessionMiddleware without a req object * sync with the new tRPC structure * tRPC refactor on routing form app * import Prisma from @prisma/client * Lazy load apps from appstore * remove unrelated changes * Add types for PaymentService * type fixes * Merge branch 'main' into roae85/cal-1514-set-the-user-session-only-on-the * fix typo * remove console.log * remove explicit types from apstore object * linter fixes --------- Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Hariom Balhara <[email protected]>
88 lines
2.7 KiB
TypeScript
88 lines
2.7 KiB
TypeScript
import authedProcedure from "../../../procedures/authedProcedure";
|
|
import { router } from "../../../trpc";
|
|
import { ZDeleteInputSchema } from "./delete.schema";
|
|
import { ZGetInputSchema } from "./get.schema";
|
|
import { ZUpdateInputSchema } from "./update.schema";
|
|
import { ZUpdateOIDCInputSchema } from "./updateOIDC.schema";
|
|
|
|
type SSORouterHandlerCache = {
|
|
get?: typeof import("./get.handler").getHandler;
|
|
update?: typeof import("./update.handler").updateHandler;
|
|
delete?: typeof import("./delete.handler").deleteHandler;
|
|
updateOIDC?: typeof import("./updateOIDC.handler").updateOIDCHandler;
|
|
};
|
|
|
|
const UNSTABLE_HANDLER_CACHE: SSORouterHandlerCache = {};
|
|
|
|
export const ssoRouter = router({
|
|
// Retrieve SSO Connection
|
|
get: authedProcedure.input(ZGetInputSchema).query(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.get) {
|
|
UNSTABLE_HANDLER_CACHE.get = await import("./get.handler").then((mod) => mod.getHandler);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.get) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.get({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
// Update the SAML Connection
|
|
update: authedProcedure.input(ZUpdateInputSchema).mutation(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.update) {
|
|
UNSTABLE_HANDLER_CACHE.update = await import("./update.handler").then((mod) => mod.updateHandler);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.update) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.update({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
// Delete the SAML Connection
|
|
delete: authedProcedure.input(ZDeleteInputSchema).mutation(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.delete) {
|
|
UNSTABLE_HANDLER_CACHE.delete = await import("./delete.handler").then((mod) => mod.deleteHandler);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.delete) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.delete({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
// Update the OIDC Connection
|
|
updateOIDC: authedProcedure.input(ZUpdateOIDCInputSchema).mutation(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.updateOIDC) {
|
|
UNSTABLE_HANDLER_CACHE.updateOIDC = await import("./updateOIDC.handler").then(
|
|
(mod) => mod.updateOIDCHandler
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.updateOIDC) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.updateOIDC({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
});
|