2023-05-09 19:27:05 +00:00
|
|
|
import sessionMiddleware from "../../middlewares/sessionMiddleware";
|
|
|
|
import publicProcedure from "../../procedures/publicProcedure";
|
2023-08-24 10:19:24 +00:00
|
|
|
import { importHandler, router } from "../../trpc";
|
2023-04-25 22:39:47 +00:00
|
|
|
import { slotsRouter } from "../viewer/slots/_router";
|
|
|
|
import { ZEventInputSchema } from "./event.schema";
|
2023-08-19 00:46:17 +00:00
|
|
|
import { i18nInputSchema } from "./i18n.schema";
|
2023-04-25 22:39:47 +00:00
|
|
|
import { ZSamlTenantProductInputSchema } from "./samlTenantProduct.schema";
|
|
|
|
import { ZStripeCheckoutSessionInputSchema } from "./stripeCheckoutSession.schema";
|
|
|
|
|
2023-08-24 10:19:24 +00:00
|
|
|
const NAMESPACE = "publicViewer";
|
2023-04-25 22:39:47 +00:00
|
|
|
|
2023-08-24 10:19:24 +00:00
|
|
|
const namespaced = (s: string) => `${NAMESPACE}.${s}`;
|
2023-04-25 22:39:47 +00:00
|
|
|
|
|
|
|
// things that unauthenticated users can query about themselves
|
|
|
|
export const publicViewerRouter = router({
|
2023-08-24 10:19:24 +00:00
|
|
|
session: publicProcedure.use(sessionMiddleware).query(async (opts) => {
|
|
|
|
const handler = await importHandler(namespaced("session"), () => import("./session.handler"));
|
|
|
|
return handler(opts);
|
2023-04-25 22:39:47 +00:00
|
|
|
}),
|
2023-08-24 10:19:24 +00:00
|
|
|
i18n: publicProcedure.input(i18nInputSchema).query(async (opts) => {
|
|
|
|
const handler = await importHandler(namespaced("i18n"), () => import("./i18n.handler"));
|
|
|
|
return handler(opts);
|
2023-04-25 22:39:47 +00:00
|
|
|
}),
|
2023-08-24 10:19:24 +00:00
|
|
|
countryCode: publicProcedure.query(async (opts) => {
|
|
|
|
const handler = await importHandler(namespaced("countryCode"), () => import("./countryCode.handler"));
|
|
|
|
return handler(opts);
|
2023-04-25 22:39:47 +00:00
|
|
|
}),
|
2023-08-24 10:19:24 +00:00
|
|
|
samlTenantProduct: publicProcedure.input(ZSamlTenantProductInputSchema).mutation(async (opts) => {
|
|
|
|
const handler = await importHandler(
|
|
|
|
namespaced("samlTenantProduct"),
|
|
|
|
() => import("./samlTenantProduct.handler")
|
|
|
|
);
|
|
|
|
return handler(opts);
|
2023-04-25 22:39:47 +00:00
|
|
|
}),
|
2023-08-24 10:19:24 +00:00
|
|
|
stripeCheckoutSession: publicProcedure.input(ZStripeCheckoutSessionInputSchema).query(async (opts) => {
|
|
|
|
const handler = await importHandler(
|
|
|
|
namespaced("stripeCheckoutSession"),
|
|
|
|
() => import("./stripeCheckoutSession.handler")
|
|
|
|
);
|
|
|
|
return handler(opts);
|
2023-05-09 19:27:05 +00:00
|
|
|
}),
|
|
|
|
cityTimezones: publicProcedure.query(async () => {
|
2023-08-24 10:19:24 +00:00
|
|
|
const handler = await importHandler(namespaced("cityTimezones"), () => import("./cityTimezones.handler"));
|
|
|
|
return handler();
|
2023-04-25 22:39:47 +00:00
|
|
|
}),
|
|
|
|
// REVIEW: This router is part of both the public and private viewer router?
|
|
|
|
slots: slotsRouter,
|
2023-08-24 10:19:24 +00:00
|
|
|
event: publicProcedure.input(ZEventInputSchema).query(async (opts) => {
|
|
|
|
const handler = await importHandler(namespaced("event"), () => import("./event.handler"));
|
|
|
|
return handler(opts);
|
2023-04-25 22:39:47 +00:00
|
|
|
}),
|
|
|
|
});
|