Skip to content

Commit e41a1da

Browse files
committed
mer log
1 parent 0639459 commit e41a1da

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

apps/dine-pleiepenger/src/pages/api/appStatus.api.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ const sanityConfig: SanityConfig = {
1212
dataset: browserEnv.NEXT_PUBLIC_APPSTATUS_DATASET,
1313
};
1414

15-
export const fetchAppStatus = async (): Promise<ApplicationState> => {
15+
export const fetchAppStatus = async (): Promise<ApplicationState | undefined> => {
1616
return await fetchStatus(APPLICATION_KEY, sanityConfig);
1717
};
1818

1919
async function handler(req: NextApiRequest, res: NextApiResponse) {
20+
const childLogger = createChildLogger(getXRequestId(req));
21+
childLogger.info(`Henter appStatus`);
2022
try {
2123
res.send(await fetchAppStatus());
2224
} catch (err) {

packages/appstatus-react-ds/src/utils/fetchStatus.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { SanityConfig } from '..';
2-
import { defaultAppStatus, getStateForApplication } from '../hooks/useAppStatus';
2+
import { getStateForApplication } from '../hooks/useAppStatus';
33
import { ApplicationState, getApplicationDocumentStatusQuery } from '../hooks/useGetApplicationStatus';
44
import { getTeamStatusQuery } from '../hooks/useGetTeamStatus';
55
import { getAppSanityClient } from './sanityClient';
66

7-
export const fetchStatus = async (applicationKey: string, sanityConfig: SanityConfig): Promise<ApplicationState> => {
7+
export const fetchStatus = async (
8+
applicationKey: string,
9+
sanityConfig: SanityConfig,
10+
): Promise<ApplicationState | undefined> => {
811
const client = getAppSanityClient(sanityConfig);
912
try {
1013
const [appResult, teamResult] = await Promise.allSettled([
@@ -17,7 +20,7 @@ export const fetchStatus = async (applicationKey: string, sanityConfig: SanityCo
1720
teamResult.status === 'fulfilled' && teamResult.value.length === 1 ? teamResult.value[0] : undefined;
1821

1922
if (!app) {
20-
return defaultAppStatus;
23+
return undefined;
2124
}
2225

2326
return getStateForApplication(
@@ -26,7 +29,7 @@ export const fetchStatus = async (applicationKey: string, sanityConfig: SanityCo
2629
team?.teamApplicationStatus.status,
2730
team?.message ? team.message[0] : undefined,
2831
);
29-
} catch {
30-
return Promise.resolve(defaultAppStatus);
32+
} catch (err) {
33+
throw new Error(`Could not load appStatus [${err}]`);
3134
}
3235
};

0 commit comments

Comments
 (0)