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