Skip to content

Commit

Permalink
IS-1903: Flexjar config
Browse files Browse the repository at this point in the history
  • Loading branch information
andersrognstad committed Jan 4, 2024
1 parent 00925e0 commit 364d187
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ NODE_ENV=development
SESSION_KEY=dette-er-en-lang-og-sikker-streng-for-signering-av-session-cookies
AUTH_REDIRECT_URI=http://localhost:8080/oauth2/callback
EREG_HOST=ereg-services-q1.dev-fss-pub.nais.io
FLEXJAR_AAD_APP_CLIENT_ID=dev-gcp.flex.flexjar-backend
FLEXJAR_HOST=http://flexjar-backend.intern.dev.nav.no
INTERNARBEIDSFLATEDECORATOR_HOST=internarbeidsflatedecorator-q0.dev.intern.nav.no
MODIACONTEXTHOLDER_HOST=modiacontextholder-q1.dev.intern.nav.no
SYFOOVERSIKTSRV_HOST=syfooversiktsrv.intern.nav.no
Expand Down
6 changes: 6 additions & 0 deletions .nais/naiserator-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ spec:
- application: syfoperson
- application: syfoveileder
- application: syfooversikt-redis
- application: flexjar-backend
namespace: flex
ingresses:
- "https://syfooversikt.intern.dev.nav.no"
env:
Expand Down Expand Up @@ -91,3 +93,7 @@ spec:
value: "http://syfoperson"
- name: SYFOVEILEDER_HOST
value: "http://syfoveileder"
- name: FLEXJAR_AAD_APP_CLIENT_ID
value: "dev-gcp.flex.flexjar-backend"
- name: FLEXJAR_HOST
value: "http://flexjar-backend.flex"
6 changes: 6 additions & 0 deletions .nais/naiserator-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ spec:
- application: syfoperson
- application: syfoveileder
- application: syfooversikt-redis
- application: flexjar-backend
namespace: flex
ingresses:
- "https://syfooversikt.intern.nav.no"
env:
Expand Down Expand Up @@ -91,3 +93,7 @@ spec:
value: "http://syfoperson"
- name: SYFOVEILEDER_HOST
value: "http://syfoveileder"
- name: FLEXJAR_AAD_APP_CLIENT_ID
value: "prod-gcp.flex.flexjar-backend"
- name: FLEXJAR_HOST
value: "http://flexjar-backend.flex"
11 changes: 11 additions & 0 deletions mock/flexjar/mockFlexjar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { FLEXJAR_ROOT } from '../../src/apiConstants';
import express from 'express';

export const mockFlexjar = (server: any) => {
server.post(
`${FLEXJAR_ROOT}/feedback/azure`,
(req: express.Request, res: express.Response) => {
res.sendStatus(200);
}
);
};
2 changes: 2 additions & 0 deletions mock/mockEndepunkter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { mockChangelogs } from './changelogs/mockChangelogs';
import { mockUnleash } from './mockUnleash';
import { mockEreg } from './ereg/mockEreg';
import { generatePersons } from './mockUtils';
import { mockFlexjar } from './flexjar/mockFlexjar';

const generatedPersons = generatePersons(50);

Expand All @@ -18,6 +19,7 @@ const mockEndepunkter = (server: express.Application) => {
[
mockModiacontextholder,
mockEreg,
mockFlexjar,
mockPersonoversikt,
mockPersontildeling,
mockSyfoperson,
Expand Down
8 changes: 8 additions & 0 deletions server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ export const auth = {
name: 'SYFOVEILEDER_HOST',
}),
},
flexjar: {
clientId: envVar({
name: 'FLEXJAR_AAD_APP_CLIENT_ID',
}),
host: envVar({
name: 'FLEXJAR_HOST',
}),
},
};

export const unleash: { serverApiUrl: string; serverApiToken: string } = {
Expand Down
11 changes: 11 additions & 0 deletions server/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,16 @@ export const setupProxy = (
})
);

router.use(
'/flexjar-backend/*',
(
req: express.Request,
res: express.Response,
next: express.NextFunction
) => {
proxyOnBehalfOf(req, res, next, authClient, issuer, Config.auth.flexjar);
}
);

return router;
};
1 change: 1 addition & 0 deletions server/unleash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ export const getToggles = (veilederId: any, enhetId: any) => {
};
return {
isHuskelappEnabled: unleash.isEnabled('isHuskelappEnabled', context),
isFlexjarEnabled: unleash.isEnabled('isFlexjarEnabled', context),
};
};
3 changes: 2 additions & 1 deletion src/api/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export const get = <ResponseData>(

export const post = <ResponseData>(
url: string,
data: Record<string, unknown> | Record<string, unknown>[],
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: Record<string, any> | Record<string, any>[],
personIdent?: string
): Promise<ResponseData> => {
return axios
Expand Down
1 change: 1 addition & 0 deletions src/apiConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export const PERSONTILDELING_ROOT = '/api/v2/persontildeling';
export const CHANGELOG_ROOT = '/syfooversikt/changelogs';
export const UNLEASH_ROOT = '/unleash';
export const EREG_ROOT = '/ereg/api/v1';
export const FLEXJAR_ROOT = '/flexjar-backend/api/v1';
20 changes: 20 additions & 0 deletions src/data/flexjar/useFlexjarFeedback.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useMutation } from '@tanstack/react-query';
import { FLEXJAR_ROOT } from '@/apiConstants';
import { post } from '@/api/axios';

export const useFlexjarFeedback = () => {
const path = `${FLEXJAR_ROOT}/feedback/azure`;
const postFlexjarFeedback = (feedback: FlexjarFeedbackDTO) =>
post(path, feedback);

return useMutation({
mutationFn: postFlexjarFeedback,
});
};

export interface FlexjarFeedbackDTO {
feedbackId: string;
feedback: string | undefined;
svar: string | undefined;
app: string;
}
2 changes: 2 additions & 0 deletions src/data/unleash/types/unleash_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ export type Toggles = {
// See toggles: https://teamsykefravr-unleash-web.nav.cloud.nais.io/features
export enum ToggleNames {
isHuskelappEnabled = 'isHuskelappEnabled',
isFlexjarEnabled = 'isFlexjarEnabled',
}

export const defaultToggles: Toggles = {
isHuskelappEnabled: false,
isFlexjarEnabled: false,
};

0 comments on commit 364d187

Please sign in to comment.