mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 02:45:39 -04:00
Replace nested loop queries with batch fetches using inArray() across discovery, tracking, metadata, settings, and system-health services. The biggest win is getContinueWatchingFeed() going from ~375+ queries to 5. Add a cached getSession() wrapper via React.cache() to deduplicate auth lookups shared between layouts and pages. Parallelize independent async operations in importTitle(), cacheImagesJob(), and the explore page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
14 lines
461 B
TypeScript
14 lines
461 B
TypeScript
import { headers } from "next/headers";
|
|
import { cache } from "react";
|
|
import { auth } from "./server";
|
|
|
|
/**
|
|
* Cached session getter — deduplicated per request via React.cache().
|
|
* Use this instead of calling auth.api.getSession() directly in server
|
|
* components and layouts to avoid redundant session lookups within a
|
|
* single render pass.
|
|
*/
|
|
export const getSession = cache(async () => {
|
|
return auth.api.getSession({ headers: await headers() });
|
|
});
|