Merge pull request #54 from sambecker/edge-tree-shake
Reduce size of edge functions
This commit is contained in:
commit
e98b78da34
@ -1,4 +1,4 @@
|
|||||||
import { authCached } from '@/cache';
|
import { authCached } from '@/auth/cache';
|
||||||
import AdminPhotoMenuClient, { AdminPhotoMenuClientProps }
|
import AdminPhotoMenuClient, { AdminPhotoMenuClientProps }
|
||||||
from './AdminPhotoMenuClient';
|
from './AdminPhotoMenuClient';
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import AdminNav from '@/admin/AdminNav';
|
import AdminNav from '@/admin/AdminNav';
|
||||||
import {
|
import {
|
||||||
getStorageUploadUrlsNoStore,
|
|
||||||
getPhotosCountIncludingHiddenCached,
|
getPhotosCountIncludingHiddenCached,
|
||||||
getUniqueTagsCached,
|
getUniqueTagsCached,
|
||||||
} from '@/cache';
|
} from '@/photo/cache';
|
||||||
|
import { getStorageUploadUrlsNoStore } from '@/services/storage/cache';
|
||||||
import {
|
import {
|
||||||
PATH_ADMIN_PHOTOS,
|
PATH_ADMIN_PHOTOS,
|
||||||
PATH_ADMIN_TAGS,
|
PATH_ADMIN_TAGS,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
import { getPhotoNoStore, getUniqueTagsCached } from '@/cache';
|
import { getPhotoNoStore, getUniqueTagsCached } from '@/photo/cache';
|
||||||
import { PATH_ADMIN } from '@/site/paths';
|
import { PATH_ADMIN } from '@/site/paths';
|
||||||
import PhotoEditPageClient from '@/photo/PhotoEditPageClient';
|
import PhotoEditPageClient from '@/photo/PhotoEditPageClient';
|
||||||
|
|
||||||
|
|||||||
@ -14,10 +14,9 @@ import {
|
|||||||
import { titleForPhoto } from '@/photo';
|
import { titleForPhoto } from '@/photo';
|
||||||
import MorePhotos from '@/photo/MorePhotos';
|
import MorePhotos from '@/photo/MorePhotos';
|
||||||
import {
|
import {
|
||||||
getStoragePhotoUrlsNoStore,
|
|
||||||
getPhotosCached,
|
getPhotosCached,
|
||||||
getPhotosCountIncludingHiddenCached,
|
getPhotosCountIncludingHiddenCached,
|
||||||
} from '@/cache';
|
} from '@/photo/cache';
|
||||||
import { AiOutlineEyeInvisible } from 'react-icons/ai';
|
import { AiOutlineEyeInvisible } from 'react-icons/ai';
|
||||||
import {
|
import {
|
||||||
PaginationParams,
|
PaginationParams,
|
||||||
@ -30,6 +29,7 @@ import StorageUrls from '@/admin/StorageUrls';
|
|||||||
import { PRO_MODE_ENABLED } from '@/site/config';
|
import { PRO_MODE_ENABLED } from '@/site/config';
|
||||||
import SubmitButtonWithStatus from '@/components/SubmitButtonWithStatus';
|
import SubmitButtonWithStatus from '@/components/SubmitButtonWithStatus';
|
||||||
import IconGrSync from '@/site/IconGrSync';
|
import IconGrSync from '@/site/IconGrSync';
|
||||||
|
import { getStoragePhotoUrlsNoStore } from '@/services/storage/cache';
|
||||||
|
|
||||||
const DEBUG_PHOTO_BLOBS = false;
|
const DEBUG_PHOTO_BLOBS = false;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import AdminChildPage from '@/components/AdminChildPage';
|
import AdminChildPage from '@/components/AdminChildPage';
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
import { getPhotosCached, getPhotosTagCountCached } from '@/cache';
|
import { getPhotosCached, getPhotosTagCountCached } from '@/photo/cache';
|
||||||
import TagForm from '@/tag/TagForm';
|
import TagForm from '@/tag/TagForm';
|
||||||
import { PATH_ADMIN, PATH_ADMIN_TAGS, pathForTag } from '@/site/paths';
|
import { PATH_ADMIN, PATH_ADMIN_TAGS, pathForTag } from '@/site/paths';
|
||||||
import PhotoTag from '@/tag/PhotoTag';
|
import PhotoTag from '@/tag/PhotoTag';
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import AdminGrid from '@/admin/AdminGrid';
|
|||||||
import { Fragment } from 'react';
|
import { Fragment } from 'react';
|
||||||
import DeleteButton from '@/admin/DeleteButton';
|
import DeleteButton from '@/admin/DeleteButton';
|
||||||
import { photoQuantityText } from '@/photo';
|
import { photoQuantityText } from '@/photo';
|
||||||
import { getUniqueTagsHiddenCached } from '@/cache';
|
import { getUniqueTagsHiddenCached } from '@/photo/cache';
|
||||||
import PhotoTag from '@/tag/PhotoTag';
|
import PhotoTag from '@/tag/PhotoTag';
|
||||||
import { formatTag, isTagFavs, sortTagsObject } from '@/tag';
|
import { formatTag, isTagFavs, sortTagsObject } from '@/tag';
|
||||||
import EditButton from '@/admin/EditButton';
|
import EditButton from '@/admin/EditButton';
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import AdminChildPage from '@/components/AdminChildPage';
|
|||||||
import { PATH_ADMIN, PATH_ADMIN_UPLOADS } from '@/site/paths';
|
import { PATH_ADMIN, PATH_ADMIN_UPLOADS } from '@/site/paths';
|
||||||
import { extractExifDataFromBlobPath } from '@/photo/server';
|
import { extractExifDataFromBlobPath } from '@/photo/server';
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
import { getUniqueTagsCached } from '@/cache';
|
import { getUniqueTagsCached } from '@/photo/cache';
|
||||||
|
|
||||||
interface Params {
|
interface Params {
|
||||||
params: { uploadPath: string }
|
params: { uploadPath: string }
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import StorageUrls from '@/admin/StorageUrls';
|
import StorageUrls from '@/admin/StorageUrls';
|
||||||
import { getStorageUploadUrlsNoStore } from '@/cache';
|
import { getStorageUploadUrlsNoStore } from '@/services/storage/cache';
|
||||||
import SiteGrid from '@/components/SiteGrid';
|
import SiteGrid from '@/components/SiteGrid';
|
||||||
|
|
||||||
export default async function AdminUploadsPage() {
|
export default async function AdminUploadsPage() {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getPhotosCached } from '@/cache';
|
import { getPhotosCached } from '@/photo/cache';
|
||||||
import { API_PHOTO_REQUEST_LIMIT, formatPhotoForApi } from '@/site/api';
|
import { API_PHOTO_REQUEST_LIMIT, formatPhotoForApi } from '@/site/api';
|
||||||
import {
|
import {
|
||||||
BASE_URL,
|
BASE_URL,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { auth } from '@/auth';
|
import { auth } from '@/auth';
|
||||||
import { revalidateAdminPaths, revalidatePhotosKey } from '@/cache';
|
import { revalidateAdminPaths, revalidatePhotosKey } from '@/photo/cache';
|
||||||
import {
|
import {
|
||||||
ACCEPTED_PHOTO_FILE_TYPES,
|
ACCEPTED_PHOTO_FILE_TYPES,
|
||||||
MAX_PHOTO_UPLOAD_SIZE_IN_BYTES,
|
MAX_PHOTO_UPLOAD_SIZE_IN_BYTES,
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import {
|
|||||||
absolutePathForPhotoImage,
|
absolutePathForPhotoImage,
|
||||||
} from '@/site/paths';
|
} from '@/site/paths';
|
||||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||||
import { getPhotoCached } from '@/cache';
|
import { getPhotoCached } from '@/photo/cache';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { FilmSimulation } from '@/simulation';
|
import { FilmSimulation } from '@/simulation';
|
||||||
import { getPhotosFilmSimulationDataCached } from '@/simulation/data';
|
import { getPhotosFilmSimulationDataCached } from '@/simulation/data';
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getPhotoCached } from '@/cache';
|
import { getPhotoCached } from '@/photo/cache';
|
||||||
import PhotoShareModal from '@/photo/PhotoShareModal';
|
import PhotoShareModal from '@/photo/PhotoShareModal';
|
||||||
import { FilmSimulation } from '@/simulation';
|
import { FilmSimulation } from '@/simulation';
|
||||||
import { PATH_ROOT } from '@/site/paths';
|
import { PATH_ROOT } from '@/site/paths';
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import { auth } from '@/auth';
|
import { getPhotosCached } from '@/photo/cache';
|
||||||
import { getImageCacheHeadersForAuth, getPhotosCached } from '@/cache';
|
|
||||||
import {
|
import {
|
||||||
IMAGE_OG_DIMENSION_SMALL,
|
IMAGE_OG_DIMENSION_SMALL,
|
||||||
MAX_PHOTOS_TO_SHOW_PER_TAG,
|
MAX_PHOTOS_TO_SHOW_PER_TAG,
|
||||||
} from '@/photo/image-response';
|
} from '@/image-response';
|
||||||
import FilmSimulationImageResponse from
|
import FilmSimulationImageResponse from
|
||||||
'@/photo/image-response/FilmSimulationImageResponse';
|
'@/image-response/FilmSimulationImageResponse';
|
||||||
import { FilmSimulation } from '@/simulation';
|
import { FilmSimulation } from '@/simulation';
|
||||||
import { getIBMPlexMonoMedium } from '@/site/font';
|
import { getIBMPlexMonoMedium } from '@/site/font';
|
||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
|
import { getImageResponseCacheControlHeaders } from '@/image-response/cache';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ export async function GET(
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_PER_TAG, simulation }),
|
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_PER_TAG, simulation }),
|
||||||
getIBMPlexMonoMedium(),
|
getIBMPlexMonoMedium(),
|
||||||
getImageCacheHeadersForAuth(await auth()),
|
getImageResponseCacheControlHeaders(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const { width, height } = IMAGE_OG_DIMENSION_SMALL;
|
const { width, height } = IMAGE_OG_DIMENSION_SMALL;
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { getPhotosCached } from '@/cache';
|
import { getPhotosCached } from '@/photo/cache';
|
||||||
import SiteGrid from '@/components/SiteGrid';
|
import SiteGrid from '@/components/SiteGrid';
|
||||||
import { generateOgImageMetaForPhotos } from '@/photo';
|
import { generateOgImageMetaForPhotos } from '@/photo';
|
||||||
import PhotoGrid from '@/photo/PhotoGrid';
|
import PhotoGrid from '@/photo/PhotoGrid';
|
||||||
import PhotosEmptyState from '@/photo/PhotosEmptyState';
|
import PhotosEmptyState from '@/photo/PhotosEmptyState';
|
||||||
import { MAX_PHOTOS_TO_SHOW_OG } from '@/photo/image-response';
|
import { MAX_PHOTOS_TO_SHOW_OG } from '@/image-response';
|
||||||
import { pathForGrid } from '@/site/paths';
|
import { pathForGrid } from '@/site/paths';
|
||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { auth } from '@/auth';
|
import { getPhotosCached } from '@/photo/cache';
|
||||||
import { getImageCacheHeadersForAuth, getPhotosCached } from '@/cache';
|
|
||||||
import {
|
import {
|
||||||
IMAGE_OG_DIMENSION_SMALL,
|
IMAGE_OG_DIMENSION_SMALL,
|
||||||
MAX_PHOTOS_TO_SHOW_OG,
|
MAX_PHOTOS_TO_SHOW_OG,
|
||||||
} from '@/photo/image-response';
|
} from '@/image-response';
|
||||||
import HomeImageResponse from '@/photo/image-response/HomeImageResponse';
|
import HomeImageResponse from '@/image-response/HomeImageResponse';
|
||||||
import { getIBMPlexMonoMedium } from '@/site/font';
|
import { getIBMPlexMonoMedium } from '@/site/font';
|
||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
|
import { getImageResponseCacheControlHeaders } from '@/image-response/cache';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ export async function GET() {
|
|||||||
{ fontFamily, fonts },
|
{ fontFamily, fonts },
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_OG }),
|
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_OG }),
|
||||||
getImageCacheHeadersForAuth(await auth()),
|
getImageResponseCacheControlHeaders(),
|
||||||
getIBMPlexMonoMedium(),
|
getIBMPlexMonoMedium(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getPhotosCached, getPhotosCountCached } from '@/cache';
|
import { getPhotosCached, getPhotosCountCached } from '@/photo/cache';
|
||||||
import MorePhotos from '@/photo/MorePhotos';
|
import MorePhotos from '@/photo/MorePhotos';
|
||||||
import StaggeredOgPhotos from '@/photo/StaggeredOgPhotos';
|
import StaggeredOgPhotos from '@/photo/StaggeredOgPhotos';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { auth } from '@/auth';
|
import { getPhotoCached } from '@/photo/cache';
|
||||||
import { getImageCacheHeadersForAuth, getPhotoCached } from '@/cache';
|
import { IMAGE_OG_DIMENSION } from '@/image-response';
|
||||||
import { IMAGE_OG_DIMENSION } from '@/photo/image-response';
|
import PhotoImageResponse from '@/image-response/PhotoImageResponse';
|
||||||
import PhotoImageResponse from '@/photo/image-response/PhotoImageResponse';
|
|
||||||
import { getIBMPlexMonoMedium } from '@/site/font';
|
import { getIBMPlexMonoMedium } from '@/site/font';
|
||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
|
import { getImageResponseCacheControlHeaders } from '@/image-response/cache';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ export async function GET(
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotoCached(context.params.photoId),
|
getPhotoCached(context.params.photoId),
|
||||||
getIBMPlexMonoMedium(),
|
getIBMPlexMonoMedium(),
|
||||||
getImageCacheHeadersForAuth(await auth()),
|
getImageResponseCacheControlHeaders(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!photo) { return new Response('Photo not found', { status: 404 }); }
|
if (!photo) { return new Response('Photo not found', { status: 404 }); }
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import {
|
|||||||
absolutePathForPhotoImage,
|
absolutePathForPhotoImage,
|
||||||
} from '@/site/paths';
|
} from '@/site/paths';
|
||||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||||
import { getPhotoCached, getPhotosNearIdCached } from '@/cache';
|
import { getPhotoCached, getPhotosNearIdCached } from '@/photo/cache';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getPhotoCached } from '@/cache';
|
import { getPhotoCached } from '@/photo/cache';
|
||||||
import PhotoShareModal from '@/photo/PhotoShareModal';
|
import PhotoShareModal from '@/photo/PhotoShareModal';
|
||||||
import { PATH_ROOT } from '@/site/paths';
|
import { PATH_ROOT } from '@/site/paths';
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getPhotosCached, getPhotosCountCached } from '@/cache';
|
import { getPhotosCached, getPhotosCountCached } from '@/photo/cache';
|
||||||
import AnimateItems from '@/components/AnimateItems';
|
import AnimateItems from '@/components/AnimateItems';
|
||||||
import MorePhotos from '@/photo/MorePhotos';
|
import MorePhotos from '@/photo/MorePhotos';
|
||||||
import SiteGrid from '@/components/SiteGrid';
|
import SiteGrid from '@/components/SiteGrid';
|
||||||
@ -11,7 +11,7 @@ import {
|
|||||||
} from '@/site/pagination';
|
} from '@/site/pagination';
|
||||||
import { pathForRoot } from '@/site/paths';
|
import { pathForRoot } from '@/site/paths';
|
||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
import { MAX_PHOTOS_TO_SHOW_OG } from '@/photo/image-response';
|
import { MAX_PHOTOS_TO_SHOW_OG } from '@/image-response';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { getPhotosCached } from '@/cache';
|
import { getPhotosCached } from '@/photo/cache';
|
||||||
import InfoBlock from '@/components/InfoBlock';
|
import InfoBlock from '@/components/InfoBlock';
|
||||||
import RedirectOnDesktop from '@/components/RedirectOnDesktop';
|
import RedirectOnDesktop from '@/components/RedirectOnDesktop';
|
||||||
import SiteGrid from '@/components/SiteGrid';
|
import SiteGrid from '@/components/SiteGrid';
|
||||||
import { generateOgImageMetaForPhotos } from '@/photo';
|
import { generateOgImageMetaForPhotos } from '@/photo';
|
||||||
import PhotoGridSidebar from '@/photo/PhotoGridSidebar';
|
import PhotoGridSidebar from '@/photo/PhotoGridSidebar';
|
||||||
import { getPhotoSidebarDataCached } from '@/photo/data';
|
import { getPhotoSidebarDataCached } from '@/photo/data';
|
||||||
import { MAX_PHOTOS_TO_SHOW_OG } from '@/photo/image-response';
|
import { MAX_PHOTOS_TO_SHOW_OG } from '@/image-response';
|
||||||
import { PATH_GRID } from '@/site/paths';
|
import { PATH_GRID } from '@/site/paths';
|
||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import {
|
|||||||
absolutePathForPhotoImage,
|
absolutePathForPhotoImage,
|
||||||
} from '@/site/paths';
|
} from '@/site/paths';
|
||||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||||
import { getPhotoCached } from '@/cache';
|
import { getPhotoCached } from '@/photo/cache';
|
||||||
import { cameraFromPhoto } from '@/camera';
|
import { cameraFromPhoto } from '@/camera';
|
||||||
import { getPhotosCameraDataCached } from '@/camera/data';
|
import { getPhotosCameraDataCached } from '@/camera/data';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getPhotoCached } from '@/cache';
|
import { getPhotoCached } from '@/photo/cache';
|
||||||
import { cameraFromPhoto } from '@/camera';
|
import { cameraFromPhoto } from '@/camera';
|
||||||
import PhotoShareModal from '@/photo/PhotoShareModal';
|
import PhotoShareModal from '@/photo/PhotoShareModal';
|
||||||
import { PATH_ROOT } from '@/site/paths';
|
import { PATH_ROOT } from '@/site/paths';
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import { auth } from '@/auth';
|
import { getPhotosCached } from '@/photo/cache';
|
||||||
import { getImageCacheHeadersForAuth, getPhotosCached } from '@/cache';
|
|
||||||
import { getCameraFromKey } from '@/camera';
|
import { getCameraFromKey } from '@/camera';
|
||||||
import {
|
import {
|
||||||
IMAGE_OG_DIMENSION_SMALL,
|
IMAGE_OG_DIMENSION_SMALL,
|
||||||
MAX_PHOTOS_TO_SHOW_PER_TAG,
|
MAX_PHOTOS_TO_SHOW_PER_TAG,
|
||||||
} from '@/photo/image-response';
|
} from '@/image-response';
|
||||||
import CameraImageResponse from '@/photo/image-response/CameraImageResponse';
|
import CameraImageResponse from '@/image-response/CameraImageResponse';
|
||||||
import { getIBMPlexMonoMedium } from '@/site/font';
|
import { getIBMPlexMonoMedium } from '@/site/font';
|
||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
|
import { getImageResponseCacheControlHeaders } from '@/image-response/cache';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ export async function GET(
|
|||||||
camera: camera,
|
camera: camera,
|
||||||
}),
|
}),
|
||||||
getIBMPlexMonoMedium(),
|
getIBMPlexMonoMedium(),
|
||||||
getImageCacheHeadersForAuth(await auth()),
|
getImageResponseCacheControlHeaders(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const { width, height } = IMAGE_OG_DIMENSION_SMALL;
|
const { width, height } = IMAGE_OG_DIMENSION_SMALL;
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import {
|
|||||||
absolutePathForPhotoImage,
|
absolutePathForPhotoImage,
|
||||||
} from '@/site/paths';
|
} from '@/site/paths';
|
||||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||||
import { getPhotoCached } from '@/cache';
|
import { getPhotoCached } from '@/photo/cache';
|
||||||
import { getPhotosTagDataCached } from '@/tag/data';
|
import { getPhotosTagDataCached } from '@/tag/data';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getPhotoCached } from '@/cache';
|
import { getPhotoCached } from '@/photo/cache';
|
||||||
import PhotoShareModal from '@/photo/PhotoShareModal';
|
import PhotoShareModal from '@/photo/PhotoShareModal';
|
||||||
import { PATH_ROOT } from '@/site/paths';
|
import { PATH_ROOT } from '@/site/paths';
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { auth } from '@/auth';
|
import { getPhotosCached } from '@/photo/cache';
|
||||||
import { getImageCacheHeadersForAuth, getPhotosCached } from '@/cache';
|
|
||||||
import {
|
import {
|
||||||
IMAGE_OG_DIMENSION_SMALL,
|
IMAGE_OG_DIMENSION_SMALL,
|
||||||
MAX_PHOTOS_TO_SHOW_PER_TAG,
|
MAX_PHOTOS_TO_SHOW_PER_TAG,
|
||||||
} from '@/photo/image-response';
|
} from '@/image-response';
|
||||||
import TagImageResponse from '@/photo/image-response/TagImageResponse';
|
import TagImageResponse from '@/image-response/TagImageResponse';
|
||||||
import { getIBMPlexMonoMedium } from '@/site/font';
|
import { getIBMPlexMonoMedium } from '@/site/font';
|
||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
|
import { getImageResponseCacheControlHeaders } from '@/image-response/cache';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ export async function GET(
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_PER_TAG, tag }),
|
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_PER_TAG, tag }),
|
||||||
getIBMPlexMonoMedium(),
|
getIBMPlexMonoMedium(),
|
||||||
getImageCacheHeadersForAuth(await auth()),
|
getImageResponseCacheControlHeaders(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const { width, height } = IMAGE_OG_DIMENSION_SMALL;
|
const { width, height } = IMAGE_OG_DIMENSION_SMALL;
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import { auth } from '@/auth';
|
import { getPhotosCached } from '@/photo/cache';
|
||||||
import { getImageCacheHeadersForAuth, getPhotosCached } from '@/cache';
|
|
||||||
import {
|
import {
|
||||||
IMAGE_OG_DIMENSION,
|
IMAGE_OG_DIMENSION,
|
||||||
MAX_PHOTOS_TO_SHOW_TEMPLATE_TIGHT,
|
MAX_PHOTOS_TO_SHOW_TEMPLATE_TIGHT,
|
||||||
} from '@/photo/image-response';
|
} from '@/image-response';
|
||||||
import TemplateImageResponse from
|
import TemplateImageResponse from
|
||||||
'@/photo/image-response/TemplateImageResponse';
|
'@/image-response/TemplateImageResponse';
|
||||||
import { getIBMPlexMonoMedium } from '@/site/font';
|
import { getIBMPlexMonoMedium } from '@/site/font';
|
||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
|
import { getImageResponseCacheControlHeaders } from '@/image-response/cache';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ export async function GET() {
|
|||||||
limit: MAX_PHOTOS_TO_SHOW_TEMPLATE_TIGHT,
|
limit: MAX_PHOTOS_TO_SHOW_TEMPLATE_TIGHT,
|
||||||
}),
|
}),
|
||||||
getIBMPlexMonoMedium(),
|
getIBMPlexMonoMedium(),
|
||||||
getImageCacheHeadersForAuth(await auth()),
|
getImageResponseCacheControlHeaders(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const { width, height } = IMAGE_OG_DIMENSION;
|
const { width, height } = IMAGE_OG_DIMENSION;
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import { auth } from '@/auth';
|
import { getPhotosCached } from '@/photo/cache';
|
||||||
import { getImageCacheHeadersForAuth, getPhotosCached } from '@/cache';
|
|
||||||
import {
|
import {
|
||||||
GRID_OG_DIMENSION,
|
GRID_OG_DIMENSION,
|
||||||
MAX_PHOTOS_TO_SHOW_TEMPLATE,
|
MAX_PHOTOS_TO_SHOW_TEMPLATE,
|
||||||
} from '@/photo/image-response';
|
} from '@/image-response';
|
||||||
import TemplateImageResponse from
|
import TemplateImageResponse from
|
||||||
'@/photo/image-response/TemplateImageResponse';
|
'@/image-response/TemplateImageResponse';
|
||||||
import { getIBMPlexMonoMedium } from '@/site/font';
|
import { getIBMPlexMonoMedium } from '@/site/font';
|
||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
|
import { getImageResponseCacheControlHeaders } from '@/image-response/cache';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export async function GET() {
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosCached({ sortBy: 'priority', limit: MAX_PHOTOS_TO_SHOW_TEMPLATE }),
|
getPhotosCached({ sortBy: 'priority', limit: MAX_PHOTOS_TO_SHOW_TEMPLATE }),
|
||||||
getIBMPlexMonoMedium(),
|
getIBMPlexMonoMedium(),
|
||||||
getImageCacheHeadersForAuth(await auth()),
|
getImageResponseCacheControlHeaders(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const { width, height } = GRID_OG_DIMENSION;
|
const { width, height } = GRID_OG_DIMENSION;
|
||||||
|
|||||||
4
src/auth/cache.ts
Normal file
4
src/auth/cache.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import { cache } from 'react';
|
||||||
|
import { auth } from '@/auth';
|
||||||
|
|
||||||
|
export const authCached = cache(auth);
|
||||||
@ -7,7 +7,7 @@ import {
|
|||||||
getPhotosCached,
|
getPhotosCached,
|
||||||
getPhotosCameraCountCached,
|
getPhotosCameraCountCached,
|
||||||
getPhotosCameraDateRangeCached,
|
getPhotosCameraDateRangeCached,
|
||||||
} from '@/cache';
|
} from '@/photo/cache';
|
||||||
import { pathForCamera } from '@/site/paths';
|
import { pathForCamera } from '@/site/paths';
|
||||||
|
|
||||||
export const getPhotosCameraDataCached = ({
|
export const getPhotosCameraDataCached = ({
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { clsx } from 'clsx/lite';
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { BiError } from 'react-icons/bi';
|
import { BiError } from 'react-icons/bi';
|
||||||
import Spinner from '@/components/Spinner';
|
import Spinner from '@/components/Spinner';
|
||||||
import { IMAGE_OG_DIMENSION } from '../photo/image-response';
|
import { IMAGE_OG_DIMENSION } from '../image-response';
|
||||||
|
|
||||||
export type OGLoadingState = 'unloaded' | 'loading' | 'loaded' | 'failed';
|
export type OGLoadingState = 'unloaded' | 'loading' | 'loaded' | 'failed';
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Photo } from '..';
|
import { Photo } from '../photo';
|
||||||
import ImageCaption from './components/ImageCaption';
|
import ImageCaption from './components/ImageCaption';
|
||||||
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
||||||
import ImageContainer from './components/ImageContainer';
|
import ImageContainer from './components/ImageContainer';
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { Photo } from '..';
|
import { Photo } from '../photo';
|
||||||
import ImageCaption from './components/ImageCaption';
|
import ImageCaption from './components/ImageCaption';
|
||||||
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
||||||
import ImageContainer from './components/ImageContainer';
|
import ImageContainer from './components/ImageContainer';
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { SITE_DOMAIN_OR_TITLE } from '@/site/config';
|
import { SITE_DOMAIN_OR_TITLE } from '@/site/config';
|
||||||
import { Photo } from '..';
|
import { Photo } from '../photo';
|
||||||
import ImageCaption from './components/ImageCaption';
|
import ImageCaption from './components/ImageCaption';
|
||||||
import ImageContainer from './components/ImageContainer';
|
import ImageContainer from './components/ImageContainer';
|
||||||
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { Photo, shouldShowExifDataForPhoto } from '..';
|
import { Photo, shouldShowExifDataForPhoto } from '../photo';
|
||||||
import { AiFillApple } from 'react-icons/ai';
|
import { AiFillApple } from 'react-icons/ai';
|
||||||
import ImageCaption from './components/ImageCaption';
|
import ImageCaption from './components/ImageCaption';
|
||||||
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { Photo } from '..';
|
import { Photo } from '../photo';
|
||||||
import { FaStar, FaTag } from 'react-icons/fa';
|
import { FaStar, FaTag } from 'react-icons/fa';
|
||||||
import ImageCaption from './components/ImageCaption';
|
import ImageCaption from './components/ImageCaption';
|
||||||
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { Photo } from '..';
|
import { Photo } from '../photo';
|
||||||
import IconFullFrame from '@/site/IconFullFrame';
|
import IconFullFrame from '@/site/IconFullFrame';
|
||||||
import IconGrid from '@/site/IconGrid';
|
import IconGrid from '@/site/IconGrid';
|
||||||
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
import ImagePhotoGrid from './components/ImagePhotoGrid';
|
||||||
9
src/image-response/cache.ts
Normal file
9
src/image-response/cache.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export const getImageResponseCacheControlHeaders = (
|
||||||
|
shouldCache = process.env.NEXT_PUBLIC_VERCEL_ENV === 'production',
|
||||||
|
) => {
|
||||||
|
return {
|
||||||
|
'Cache-Control': shouldCache
|
||||||
|
? 's-maxage=3600, stale-while-revalidate=59'
|
||||||
|
: 's-maxage=1, stale-while-revalidate=59',
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -22,7 +22,7 @@ import {
|
|||||||
revalidateAdminPaths,
|
revalidateAdminPaths,
|
||||||
revalidateAllKeysAndPaths,
|
revalidateAllKeysAndPaths,
|
||||||
revalidatePhotosKey,
|
revalidatePhotosKey,
|
||||||
} from '@/cache';
|
} from '@/photo/cache';
|
||||||
import { PATH_ADMIN_PHOTOS, PATH_ADMIN_TAGS } from '@/site/paths';
|
import { PATH_ADMIN_PHOTOS, PATH_ADMIN_TAGS } from '@/site/paths';
|
||||||
import { extractExifDataFromBlobPath } from './server';
|
import { extractExifDataFromBlobPath } from './server';
|
||||||
import { TAG_FAVS, isTagFavs } from '@/tag';
|
import { TAG_FAVS, isTagFavs } from '@/tag';
|
||||||
|
|||||||
@ -24,12 +24,8 @@ import {
|
|||||||
getPhotosNearId,
|
getPhotosNearId,
|
||||||
} from '@/services/vercel-postgres';
|
} from '@/services/vercel-postgres';
|
||||||
import { parseCachedPhotoDates, parseCachedPhotosDates } from '@/photo';
|
import { parseCachedPhotoDates, parseCachedPhotosDates } from '@/photo';
|
||||||
import { getStoragePhotoUrls, getStorageUploadUrls } from '@/services/storage';
|
|
||||||
import type { Session } from 'next-auth';
|
|
||||||
import { createCameraKey } from '@/camera';
|
import { createCameraKey } from '@/camera';
|
||||||
import { PATHS_ADMIN } from '@/site/paths';
|
import { PATHS_ADMIN } from '@/site/paths';
|
||||||
import { cache } from 'react';
|
|
||||||
import { auth } from '@/auth';
|
|
||||||
|
|
||||||
// Table key
|
// Table key
|
||||||
const KEY_PHOTOS = 'photos';
|
const KEY_PHOTOS = 'photos';
|
||||||
@ -209,31 +205,9 @@ export const getUniqueFilmSimulationsCached =
|
|||||||
[KEY_PHOTOS, KEY_FILM_SIMULATIONS],
|
[KEY_PHOTOS, KEY_FILM_SIMULATIONS],
|
||||||
);
|
);
|
||||||
|
|
||||||
export const authCached = cache(auth);
|
// No store
|
||||||
|
|
||||||
// No Store
|
|
||||||
|
|
||||||
export const getPhotoNoStore = (...args: Parameters<typeof getPhoto>) => {
|
export const getPhotoNoStore = (...args: Parameters<typeof getPhoto>) => {
|
||||||
unstable_noStore();
|
unstable_noStore();
|
||||||
return getPhoto(...args);
|
return getPhoto(...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getStorageUploadUrlsNoStore: typeof getStorageUploadUrls =
|
|
||||||
(...args) => {
|
|
||||||
unstable_noStore();
|
|
||||||
return getStorageUploadUrls(...args);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getStoragePhotoUrlsNoStore: typeof getStoragePhotoUrls =
|
|
||||||
(...args) => {
|
|
||||||
unstable_noStore();
|
|
||||||
return getStoragePhotoUrls(...args);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getImageCacheHeadersForAuth = (session: Session | null) => {
|
|
||||||
return {
|
|
||||||
'Cache-Control': !session?.user
|
|
||||||
? 's-maxage=3600, stale-while-revalidate=59'
|
|
||||||
: 's-maxage=1, stale-while-revalidate=59',
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -3,7 +3,7 @@ import {
|
|||||||
getUniqueCamerasCached,
|
getUniqueCamerasCached,
|
||||||
getUniqueFilmSimulationsCached,
|
getUniqueFilmSimulationsCached,
|
||||||
getUniqueTagsCached,
|
getUniqueTagsCached,
|
||||||
} from '@/cache';
|
} from '@/photo/cache';
|
||||||
import { SHOW_FILM_SIMULATIONS } from '@/site/config';
|
import { SHOW_FILM_SIMULATIONS } from '@/site/config';
|
||||||
import { TAG_FAVS } from '@/tag';
|
import { TAG_FAVS } from '@/tag';
|
||||||
|
|
||||||
|
|||||||
14
src/services/storage/cache.ts
Normal file
14
src/services/storage/cache.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { unstable_noStore } from 'next/cache';
|
||||||
|
import { getStoragePhotoUrls, getStorageUploadUrls } from '@/services/storage';
|
||||||
|
|
||||||
|
export const getStorageUploadUrlsNoStore: typeof getStorageUploadUrls =
|
||||||
|
(...args) => {
|
||||||
|
unstable_noStore();
|
||||||
|
return getStorageUploadUrls(...args);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStoragePhotoUrlsNoStore: typeof getStoragePhotoUrls =
|
||||||
|
(...args) => {
|
||||||
|
unstable_noStore();
|
||||||
|
return getStoragePhotoUrls(...args);
|
||||||
|
};
|
||||||
@ -2,7 +2,7 @@ import {
|
|||||||
getPhotosCached,
|
getPhotosCached,
|
||||||
getPhotosFilmSimulationCountCached,
|
getPhotosFilmSimulationCountCached,
|
||||||
getPhotosFilmSimulationDateRangeCached,
|
getPhotosFilmSimulationDateRangeCached,
|
||||||
} from '@/cache';
|
} from '@/photo/cache';
|
||||||
import {
|
import {
|
||||||
PaginationSearchParams,
|
PaginationSearchParams,
|
||||||
getPaginationForSearchParams,
|
getPaginationForSearchParams,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { authCached } from '@/cache';
|
import { authCached } from '@/auth/cache';
|
||||||
import FooterClient from './FooterClient';
|
import FooterClient from './FooterClient';
|
||||||
|
|
||||||
export default async function Footer() {
|
export default async function Footer() {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { authCached } from '@/cache';
|
import { authCached } from '@/auth/cache';
|
||||||
import NavClient from './NavClient';
|
import NavClient from './NavClient';
|
||||||
|
|
||||||
export default async function Nav() {
|
export default async function Nav() {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import {
|
|||||||
getPhotosCached,
|
getPhotosCached,
|
||||||
getPhotosTagCountCached,
|
getPhotosTagCountCached,
|
||||||
getPhotosTagDateRangeCached,
|
getPhotosTagDateRangeCached,
|
||||||
} from '@/cache';
|
} from '@/photo/cache';
|
||||||
import {
|
import {
|
||||||
PaginationSearchParams,
|
PaginationSearchParams,
|
||||||
getPaginationForSearchParams,
|
getPaginationForSearchParams,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user