Nemila
Nemila
TTCTheo's Typesafe Cult
Created by Nemila on 1/26/2025 in #questions
Struggling to Reduce Vercel Function Invocations on My Next.js Website – Need Optimization Tips!
Solved, the extra requests were made because of the Link components. I had to set prefetch to false on my Link components
5 replies
TTCTheo's Typesafe Cult
Created by Nemila on 1/26/2025 in #questions
Struggling to Reduce Vercel Function Invocations on My Next.js Website – Need Optimization Tips!
This is the code that manipulates the database.
5 replies
TTCTheo's Typesafe Cult
Created by Nemila on 1/26/2025 in #questions
Struggling to Reduce Vercel Function Invocations on My Next.js Website – Need Optimization Tips!
This is the code inside the media action file [path: /features/media/server/actions]
export const getCachedSeasons = async (
mediaType: MediaType,
tmdbId: number,
) => {
const cacheFn = dbCache(mediaService.getSeasons, {
tags: [
getMediaGlobalTag(),
getMediaTypeTag(mediaType),
getMediaTmdbIdTag(mediaType, tmdbId),
],
});
return cacheFn(mediaType, tmdbId);
};
export const getMediaDetailsCached = async (payload: GetMediaDetailsType) => {
const valid = getMediaDetailsSchema.parse(payload);
const mediaFn = dbCache(mediaService.getDetails, {
tags: [
getMediaGlobalTag(),
getMediaTypeTag(payload.mediaType),
getMediaTmdbIdTag(payload.mediaType, payload.tmdbId),
],
});
const media = await mediaFn(valid);
if (!media) throw new Error("Media not found");
const episodeFound = media.episodes.find((i) => i.number === valid.episode);
const episode = episodeFound || media.episodes[0];
return { episode, payload: valid, media };
};
export const getMediaDetailsBatch = async (
payload: GetMediaDetailsBatchType,
) => {
const mediaDetails = await getMediaDetailsCached({
episode: payload.episode,
mediaType: payload.mediaType,
season: payload.season,
tmdbId: payload.tmdbId,
});
const seasons = await getCachedSeasons(payload.mediaType, payload.tmdbId);
return { ...mediaDetails, seasons };
};
export const getCachedSeasons = async (
mediaType: MediaType,
tmdbId: number,
) => {
const cacheFn = dbCache(mediaService.getSeasons, {
tags: [
getMediaGlobalTag(),
getMediaTypeTag(mediaType),
getMediaTmdbIdTag(mediaType, tmdbId),
],
});
return cacheFn(mediaType, tmdbId);
};
export const getMediaDetailsCached = async (payload: GetMediaDetailsType) => {
const valid = getMediaDetailsSchema.parse(payload);
const mediaFn = dbCache(mediaService.getDetails, {
tags: [
getMediaGlobalTag(),
getMediaTypeTag(payload.mediaType),
getMediaTmdbIdTag(payload.mediaType, payload.tmdbId),
],
});
const media = await mediaFn(valid);
if (!media) throw new Error("Media not found");
const episodeFound = media.episodes.find((i) => i.number === valid.episode);
const episode = episodeFound || media.episodes[0];
return { episode, payload: valid, media };
};
export const getMediaDetailsBatch = async (
payload: GetMediaDetailsBatchType,
) => {
const mediaDetails = await getMediaDetailsCached({
episode: payload.episode,
mediaType: payload.mediaType,
season: payload.season,
tmdbId: payload.tmdbId,
});
const seasons = await getCachedSeasons(payload.mediaType, payload.tmdbId);
return { ...mediaDetails, seasons };
};
5 replies
TTCTheo's Typesafe Cult
Created by Nemila on 5/11/2023 in #questions
[Solved] How to get clerk userId in a publicProcedure?
7 replies
TTCTheo's Typesafe Cult
Created by Nemila on 5/11/2023 in #questions
[Solved] How to get clerk userId in a publicProcedure?
Instead I found the solution the clerk doc
7 replies
TTCTheo's Typesafe Cult
Created by Nemila on 5/11/2023 in #questions
[Solved] How to get clerk userId in a publicProcedure?
Thank you but I tried and I couldn't get it to work
7 replies
TTCTheo's Typesafe Cult
Created by Nemila on 5/8/2023 in #questions
[Solved] How to use Vercel Cron Job with T3?
Gotcha thx
12 replies
TTCTheo's Typesafe Cult
Created by Nemila on 5/8/2023 in #questions
[Solved] How to use Vercel Cron Job with T3?
It does Cron jobs too?
12 replies
TTCTheo's Typesafe Cult
Created by Nemila on 5/8/2023 in #questions
[Solved] How to use Vercel Cron Job with T3?
@barry got it thank you
12 replies
TTCTheo's Typesafe Cult
Created by Nemila on 5/4/2023 in #questions
[Solved] T3 Stack PWA ??
I will check it out thxx
11 replies
TTCTheo's Typesafe Cult
Created by Nemila on 5/4/2023 in #questions
[Solved] T3 Stack PWA ??
You right! I didn't notice because in the doc they used required() instead of import. I need to work on the basics and read more attentively Thank you!
11 replies