cache sharing for posts. Begin infill implementation.

This commit is contained in:
2025-12-26 15:14:50 -05:00
parent b412db92e5
commit 13a22bfeb3
7 changed files with 184 additions and 76 deletions

View File

@@ -0,0 +1,33 @@
import { publicProcedure, createTRPCRouter } from "~/server/api/utils";
import { env } from "~/env/server";
// Helper to detect mobile devices from User-Agent
const isMobileDevice = (userAgent: string | undefined): boolean => {
if (!userAgent) return false;
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
userAgent
);
};
export const infillRouter = createTRPCRouter({
getConfig: publicProcedure.query(({ ctx }) => {
// Only admins get the config
if (ctx.privilegeLevel !== "admin") {
return { endpoint: null, token: null };
}
// Get User-Agent from request headers
const userAgent = ctx.event.nativeEvent.node.req.headers["user-agent"];
// Block mobile devices - infill is desktop only
if (isMobileDevice(userAgent)) {
return { endpoint: null, token: null };
}
// Return endpoint and token (or null if not configured)
return {
endpoint: env.VITE_INFILL_ENDPOINT || null,
token: env.INFILL_BEARER_TOKEN || null
};
})
});