diff --git a/pages/api/mellomlagring/lagre.ts b/pages/api/mellomlagring/lagre.ts index c4a2f3b7..10449548 100644 --- a/pages/api/mellomlagring/lagre.ts +++ b/pages/api/mellomlagring/lagre.ts @@ -1,10 +1,8 @@ import { NextApiRequest, NextApiResponse } from 'next'; -import { getAccessTokenFromRequest } from 'auth/accessToken'; import { beskyttetApi } from 'auth/beskyttetApi'; -import { logError, tokenXApiProxy } from '@navikt/aap-felles-utils'; +import { logError, logInfo } from '@navikt/aap-felles-utils'; import { lagreCache } from 'mock/mellomlagringsCache'; import { isFunctionalTest, isMock } from 'utils/environments'; -import metrics from 'utils/metrics'; import { StepType } from 'components/StepWizard/Step'; import { hentMellomlagring } from 'pages/api/mellomlagring/les'; @@ -35,14 +33,15 @@ export const mellomlagreSøknad = async (data: object, req: IncomingMessage) => if (isFunctionalTest()) return; if (isMock()) return await lagreCache(JSON.stringify(data)); try { - await simpleTokenXProxy({ + const result = await simpleTokenXProxy({ url: `${process.env.INNSENDING_URL}/mellomlagring/søknad`, method: 'POST', audience: process.env.INNSENDING_AUDIENCE!, body: data, req, }); - return; + logInfo('Søknad lagret via aap-innsending', result); + return result; } catch (error) { logError('Noe gikk galt ved mellomlagring av søknad', error); throw new Error('Error saving søknad via aap-innsending'); diff --git a/pages/api/mellomlagring/les.ts b/pages/api/mellomlagring/les.ts index c8e11b41..ca3b2c00 100644 --- a/pages/api/mellomlagring/les.ts +++ b/pages/api/mellomlagring/les.ts @@ -1,7 +1,7 @@ import { NextApiRequest, NextApiResponse } from 'next'; import { getAccessTokenFromRequest } from 'auth/accessToken'; import { beskyttetApi } from 'auth/beskyttetApi'; -import { logError, tokenXApiProxy } from '@navikt/aap-felles-utils'; +import { logError, logInfo, tokenXApiProxy } from '@navikt/aap-felles-utils'; import metrics from 'utils/metrics'; import { lesCache } from 'mock/mellomlagringsCache'; import { isFunctionalTest, isMock } from 'utils/environments'; @@ -37,7 +37,7 @@ export const hentMellomlagring = async ( audience: process.env.INNSENDING_AUDIENCE!, req, }); - + logInfo('Mellomlagret søknad hentet fra aap-innsending', mellomlagretSøknad); return mellomlagretSøknad; } catch (error: any) { logError('Noe gikk galt i henting av mellomlagring fra aap-innsending', error); diff --git a/pages/api/mellomlagring/slett.ts b/pages/api/mellomlagring/slett.ts index e9beacef..95ba4909 100644 --- a/pages/api/mellomlagring/slett.ts +++ b/pages/api/mellomlagring/slett.ts @@ -1,7 +1,7 @@ import { NextApiRequest, NextApiResponse } from 'next'; import { getAccessTokenFromRequest } from 'auth/accessToken'; import { beskyttetApi } from 'auth/beskyttetApi'; -import { logError, tokenXApiProxy } from '@navikt/aap-felles-utils'; +import { logError, logInfo, tokenXApiProxy } from '@navikt/aap-felles-utils'; import metrics from 'utils/metrics'; import { deleteCache } from 'mock/mellomlagringsCache'; import { isMock } from 'utils/environments'; @@ -21,13 +21,14 @@ export const slettBucket = async (req: IncomingMessage) => { } try { - await simpleTokenXProxy({ + const result = await simpleTokenXProxy({ url: `${process.env.INNSENDING_URL}/mellomlagring/søknad`, method: 'DELETE', audience: process.env.INNSENDING_AUDIENCE!, req, }); - return; + logInfo('Søknad slettet via aap-innsending', result); + return result; } catch (error) { logError('Noe gikk galt ved sletting av søknad', error); throw new Error('Error deleting søknad via aap-innsending');