Make queries resilient to unconfigured installations
This commit is contained in:
parent
850af1ecdf
commit
6c73b14b85
@ -23,7 +23,7 @@ export async function GET() {
|
||||
? getPhotosCached({
|
||||
limit: MAX_PHOTOS_TO_SHOW_PER_CATEGORY,
|
||||
recent: true,
|
||||
})
|
||||
}).catch(() => [])
|
||||
: [],
|
||||
getIBMPlexMono(),
|
||||
getImageResponseCacheControlHeaders(),
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo';
|
||||
import { INFINITE_SCROLL_GRID_INITIAL, Photo } from '@/photo';
|
||||
import { generateMetaForRecents } from '@/recents/meta';
|
||||
import RecentsOverview from '@/recents/RecentsOverview';
|
||||
import { getPhotosRecentsDataCached } from '@/recents/data';
|
||||
@ -9,7 +9,9 @@ import { redirect } from 'next/navigation';
|
||||
import { getAppText } from '@/i18n/state/server';
|
||||
|
||||
const getPhotosRecentsDataCachedCached = cache(() =>
|
||||
getPhotosRecentsDataCached({ limit: INFINITE_SCROLL_GRID_INITIAL }));
|
||||
getPhotosRecentsDataCached({ limit: INFINITE_SCROLL_GRID_INITIAL })
|
||||
.catch(() => [[] as Photo[], { count: 0, dateRange: undefined}] as const),
|
||||
);
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const [
|
||||
|
||||
@ -3,7 +3,12 @@ import { removeParamsFromUrl } from '@/utility/url';
|
||||
import { Pool, QueryResult, QueryResultRow } from 'pg';
|
||||
|
||||
const pool = new Pool({
|
||||
connectionString: removeParamsFromUrl(process.env.POSTGRES_URL, ['sslmode']),
|
||||
...process.env.POSTGRES_URL && {
|
||||
connectionString: removeParamsFromUrl(
|
||||
process.env.POSTGRES_URL,
|
||||
['sslmode'],
|
||||
),
|
||||
},
|
||||
...POSTGRES_SSL_ENABLED && { ssl: true },
|
||||
});
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ export const makeUrlAbsolute = (url?: string) => url !== undefined
|
||||
.replace(/\/$/, '')
|
||||
: undefined;
|
||||
|
||||
export const removeParamsFromUrl = (urlString = '', params: string[]) => {
|
||||
export const removeParamsFromUrl = (urlString: string, params: string[]) => {
|
||||
const url = new URL(urlString);
|
||||
for (const param of params) {
|
||||
url.searchParams.delete(param);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user