Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👽 Legger til nye endepunkter #128

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .nais/dev.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
RUNTIME_ENVIRONMENT="dev"
DECORATOR_ENV="dev"

SOKNAD_API_URL="http://soknad-api"
SOKNAD_API_AUDIENCE="dev-gcp:aap:soknad-api"

OPPSLAG_URL="http://oppslag"
OPPSLAG_AUDIENCE="dev-gcp:aap:oppslag"

ASSET_PREFIX="https://cdn.nav.no/aap/aap-soknad"

NEXT_PUBLIC_FARO_URL="https://telemetry.ekstern.dev.nav.no/collect"
1 change: 1 addition & 0 deletions .nais/nais.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ spec:
outbound:
rules:
- application: soknad-api
- application: oppslag
- application: nav-dekoratoren
namespace: personbruker
external:
Expand Down
5 changes: 5 additions & 0 deletions .nais/prod.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
RUNTIME_ENVIRONMENT="prod"
DECORATOR_ENV="prod"

SOKNAD_API_URL="http://soknad-api"
SOKNAD_API_AUDIENCE="prod-gcp:aap:soknad-api"

OPPSLAG_URL="http://oppslag"
OPPSLAG_AUDIENCE="prod-gcp:aap:oppslag"

ASSET_PREFIX="https://cdn.nav.no/aap/aap-soknad"
NEXT_TELEMETRY_DISABLED=1

Expand Down
27 changes: 27 additions & 0 deletions pages/api/oppslagapi/barn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { NextApiRequest, NextApiResponse } from 'next';
import { getAccessTokenFromRequest } from 'auth/accessToken';
import { beskyttetApi } from 'auth/beskyttetApi';
import { logger, tokenXApiProxy } from '@navikt/aap-felles-utils';
import metrics from 'utils/metrics';

const handler = beskyttetApi(async (req: NextApiRequest, res: NextApiResponse) => {
const accessToken = getAccessTokenFromRequest(req);
res.status(200).json(await getBarn(accessToken));
});

export const getBarn = async (accessToken?: string) => {
const barn = await tokenXApiProxy({
url: `${process.env.OPPSLAG_URL}/person/barn`,
prometheusPath: 'oppslag/barn',
method: 'GET',
audience: process.env.OPPSLAG_AUDIENCE!,
bearerToken: accessToken,
metricsStatusCodeCounter: metrics.backendApiStatusCodeCounter,
metricsTimer: metrics.backendApiDurationHistogram,
logger: logger,
});

return barn;
};

export default handler;
26 changes: 26 additions & 0 deletions pages/api/oppslagapi/fastlege.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NextApiRequest, NextApiResponse } from 'next';
import { getAccessTokenFromRequest } from 'auth/accessToken';
import { beskyttetApi } from 'auth/beskyttetApi';
import { logger, tokenXApiProxy } from '@navikt/aap-felles-utils';
import metrics from 'utils/metrics';
import { OppslagBehandler } from 'context/sokerOppslagContext';

const handler = beskyttetApi(async (req: NextApiRequest, res: NextApiResponse) => {
const accessToken = getAccessTokenFromRequest(req);
res.status(200).json(await getFastlege(accessToken));
});
export const getFastlege = async (accessToken?: string) => {
const fastlege: OppslagBehandler = await tokenXApiProxy({
url: `${process.env.OPPSLAG_URL}/fastlege`,
prometheusPath: 'oppslag/fastlege',
method: 'GET',
audience: process.env.OPPSLAG_AUDIENCE!,
bearerToken: accessToken,
metricsStatusCodeCounter: metrics.backendApiStatusCodeCounter,
metricsTimer: metrics.backendApiDurationHistogram,
logger: logger,
});
return fastlege;
};

export default handler;
26 changes: 26 additions & 0 deletions pages/api/oppslagapi/krr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NextApiRequest, NextApiResponse } from 'next';
import { getAccessTokenFromRequest } from 'auth/accessToken';
import { beskyttetApi } from 'auth/beskyttetApi';
import { logger, tokenXApiProxy } from '@navikt/aap-felles-utils';
import metrics from 'utils/metrics';
import { KontaktInfoView } from 'context/sokerOppslagContext';

const handler = beskyttetApi(async (req: NextApiRequest, res: NextApiResponse) => {
const accessToken = getAccessTokenFromRequest(req);
res.status(200).json(await getKrr(accessToken));
});
export const getKrr = async (accessToken?: string) => {
const krr: KontaktInfoView = await tokenXApiProxy({
url: `${process.env.OPPSLAG_URL}/krr`,
prometheusPath: 'oppslag/krr',
method: 'GET',
audience: process.env.OPPSLAG_AUDIENCE!,
bearerToken: accessToken,
metricsStatusCodeCounter: metrics.backendApiStatusCodeCounter,
metricsTimer: metrics.backendApiDurationHistogram,
logger: logger,
});
return krr;
};

export default handler;
24 changes: 24 additions & 0 deletions pages/api/oppslagapi/person.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { NextApiRequest, NextApiResponse } from 'next';
import { getAccessTokenFromRequest } from 'auth/accessToken';
import { beskyttetApi } from 'auth/beskyttetApi';
import { logger, tokenXApiProxy } from '@navikt/aap-felles-utils';
import metrics from 'utils/metrics';

const handler = beskyttetApi(async (req: NextApiRequest, res: NextApiResponse) => {
const accessToken = getAccessTokenFromRequest(req);
res.status(200).json(await getSøker(accessToken));
});
export const getSøker = async (accessToken?: string) => {
const søker = await tokenXApiProxy({
url: `${process.env.OPPSLAG_URL}/person`,
prometheusPath: 'oppslag/person',
method: 'GET',
audience: process.env.OPPSLAG_AUDIENCE!,
bearerToken: accessToken,
metricsStatusCodeCounter: metrics.backendApiStatusCodeCounter,
metricsTimer: metrics.backendApiDurationHistogram,
logger: logger,
});
return søker;
};
export default handler;
Loading