Skip to content

Commit

Permalink
Migrate to Fastify
Browse files Browse the repository at this point in the history
  • Loading branch information
eriksson-daniel committed Aug 30, 2024
1 parent e4f62fc commit d9ffb86
Show file tree
Hide file tree
Showing 110 changed files with 3,009 additions and 1,985 deletions.
8 changes: 0 additions & 8 deletions .dockerignore

This file was deleted.

60 changes: 30 additions & 30 deletions .github/workflows/deploy-to-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,45 @@ on:
run-name: Dev deploy of ${{ github.ref_name }}

jobs:
build:
name: Build
build-push:
name: Build and push
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install frontend dependencies
shell: bash
registry-url: https://npm.pkg.github.com/
scope: "@navikt"

- name: Generate bunfig.toml
run: |
cd frontend
bun install
echo -e "[install.scopes]\n\"@navikt\" = { token = \"${{ secrets.READER_TOKEN }}\", url = \"https://npm.pkg.github.com/\" }" > ./frontend/bunfig.toml
cp ./frontend/bunfig.toml ./server/bunfig.toml
- name: Install frontend dependencies
working-directory: ./frontend
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
BUN_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
run: bun install --frozen-lockfile

- name: Test frontend
shell: bash
run: |
cd frontend
bun test
working-directory: ./frontend
run: bun test

- name: Build frontend
shell: bash
working-directory: ./frontend
env:
VERSION: ${{ github.sha }}
run: |
cd frontend
bun run build
run: bun run build

- name: Upload static files to CDN
uses: nais/deploy/actions/cdn-upload/v2@master
Expand All @@ -74,20 +74,20 @@ jobs:
destination: klang
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}

- name: Install server dependencies
shell: bash
run: |
cd server
bun install
working-directory: ./server
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
BUN_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
run: bun install --frozen-lockfile

- name: Test server
shell: bash
run: |
cd server
bun test
working-directory: ./server
run: bun test

- name: Build server
working-directory: ./server
run: bun run build

- name: Generate version number
id: version
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
permissions:
contents: read
id-token: write
needs: build
needs: build-push
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -127,7 +127,7 @@ jobs:
CLUSTER: dev-gcp
VARS: nais/dev.yaml
RESOURCE: nais/nais.yaml
VAR: image=${{ needs.build.outputs.image }}
VAR: image=${{ needs.build-push.outputs.image }}

e2e_test:
name: E2E
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/sanity-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,26 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
registry-url: https://npm.pkg.github.com/
scope: "@navikt"

- name: Generate bunfig.toml
run: |
cd ${{ matrix.apps }}
echo -e "[install.scopes]\n\"@navikt\" = { token = \"${{ secrets.READER_TOKEN }}\", url = \"https://npm.pkg.github.com/\" }" > bunfig.toml
- name: Install ${{ matrix.apps }} dependencies
shell: bash
env:
BUN_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
run: |
cd ${{ matrix.apps }}
bun install
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
bun install --frozen-lockfile
- name: Restore caches for ${{ matrix.apps }}
uses: actions/cache/restore@v3
Expand All @@ -44,7 +52,7 @@ jobs:
shell: bash
run: |
cd ${{ matrix.apps }}
npm run lint
bun run lint
- name: Test ${{ matrix.apps }}
shell: bash
Expand Down
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bun 1.1.26
nodejs 22.7.0
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
FROM oven/bun:1
FROM node:22-alpine

ENV NODE_ENV=production
ENV NPM_CONFIG_CACHE=/tmp

WORKDIR /usr/src/app
COPY server server
COPY frontend frontend

WORKDIR /usr/src/app/server
COPY server/dist server/dist
COPY frontend/dist/index.html frontend/dist/index.html

# This command will create an absolute path reference to JSDOM (used by nav-dekoratoren-moduler), which will not work if built outside Docker
RUN bun run build
WORKDIR /usr/src/app/server

ARG VERSION
ENV VERSION=$VERSION

CMD bun run prod
CMD node --trace-warnings dist/server.js
EXPOSE 8080
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ Digital innsending av klager og anker. Samt ettersendelse.
# Komme i gang

## Autorisering mot @navikt-NPM-registeret
1. Lag et Personal Access Token (PAT) med scope: `read:packages`. _PAT-en må være autorisert for organisasjonen `navikt`._
2. Sett verdien i miljøvariabelen NODE_AUTH_TOKEN
1. [Lag et Personal Access Token (PAT)](https://github.com/settings/tokens) med scope: `read:packages`. _Tokenet må være autorisert for organisasjonen `navikt`._
2. Opprett filen `bunfig.toml` i din `$HOME`-mappe med følgende innhold:
```toml
[install.scopes]
"@navikt" = { token = "ghp_Qj6Xxn8HTUSJL9dNiZ0TW7R5YvupTZclTXsK", url = "https://npm.pkg.github.com/" }
```
3. Bytt ut `ghp_Qj6Xxn8HTUSJL9dNiZ0TW7R5YvupTZclTXsK` med ditt eget token.

### Referanser
- https://github.com/navikt/nav-dekoratoren-moduler?tab=readme-ov-file#kom-i-gang
Expand Down Expand Up @@ -64,17 +69,20 @@ For å lenke direkte til klageskjemaet må `innsendingsytelse` være satt i URL-
Saksnummeret settes i klagen/anken, men bruker kan **ikke** endre det.
Dersom dette ikke er oppgitt som query parameter, får bruker mulighet til å fylle inn saksnummer selv.

### Eksempel på fullstendig URL til klageskjema:
```
https://klage.nav.no/nb/klage/DAGPENGER?saksnummer=12345
```
### Eksempler på fullstendige URLer
| Skjema | URL |
|--------|-----|
| Klage | `https://klage.nav.no/nb/klage/DAGPENGER?saksnummer=12345` |
| Anke | `https://klage.nav.no/nb/anke/DAGPENGER?saksnummer=12345` |
| Ettersendelse til klage | `https://klage.nav.no/nb/ettersendelse/klage/DAGPENGER?saksnummer=12345` |
| Ettersendelse til anke | `https://klage.nav.no/nb/ettersendelse/anke/DAGPENGER?saksnummer=12345` |

## URL-format
```
https://klage.nav.no/{språk}/{type}/{innsendingsytelse}?saksnummer={saksnummer}
```
- `språk` = `nb | en`
- `type` = `klage | anke | ettersendelse`
- `språk` = `nb | nn | en`
- `type` = `klage | anke | ettersendelse/klage | ettersendelse/anke`
- `innsendingsytelse` = Se liste over tilgjengelige ytelser under.
- `saksnummer` = Relevant saksnummer.

Expand Down
Binary file modified frontend/bun.lockb
Binary file not shown.
2 changes: 0 additions & 2 deletions frontend/bunfig.toml

This file was deleted.

6 changes: 5 additions & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon/favicon-16x16.png" />
<script async type="module" src="/src/index.tsx"></script>
{{DECORATOR_STYLES}}
{{DECORATOR_SCRIPTS}}
<title>Klage eller anke på vedtak</title>
</head>

<body>
{{DECORATOR_HEADER}}
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
{{DECORATOR_FOOTER}}
</body>

</html>
</html>
39 changes: 20 additions & 19 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,55 @@
"license": "MIT",
"type": "module",
"scripts": {
"start": "vite & tsc --watch",
"start": "vite --base=/ & tsc --watch",
"build": "vite build",
"build:local": "vite --base=/ build",
"typecheck": "tsc",
"lint": "eslint src --color --cache --cache-strategy content --cache-location .eslintcache"
},
"devDependencies": {
"@types/bun": "1.1.6",
"@types/react": "18.3.3",
"@types/bun": "1.1.8",
"@types/react": "18.3.4",
"@types/react-dom": "18.3.0",
"@types/react-redux": "7.1.33",
"@typescript-eslint/eslint-plugin": "7.16.1",
"@typescript-eslint/parser": "7.16.1",
"@typescript-eslint/eslint-plugin": "8.3.0",
"@typescript-eslint/parser": "8.3.0",
"@vitejs/plugin-react": "^4.3.1",
"css-loader": "7.1.2",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript-bun": "0.0.98",
"eslint-import-resolver-typescript-bun": "0.0.103",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsx-a11y": "6.9.0",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-react": "7.34.4",
"eslint-plugin-react": "7.35.0",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-vitest": "0.5.4",
"prettier": "3.3.3",
"style-loader": "4.0.0",
"ts-loader": "9.5.1",
"typescript": "5.5.3",
"vite": "5.3.4",
"vite-tsconfig-paths": "4.3.2"
"typescript": "5.5.4",
"vite": "5.4.2",
"vite-tsconfig-paths": "5.0.1"
},
"dependencies": {
"@grafana/faro-react": "^1.8.2",
"@grafana/faro-web-sdk": "^1.8.2",
"@grafana/faro-web-tracing": "^1.8.2",
"@navikt/aksel-icons": "6.13.0",
"@navikt/ds-css": "6.13.0",
"@navikt/ds-react": "6.13.0",
"@grafana/faro-react": "^1.9.1",
"@grafana/faro-web-sdk": "^1.9.1",
"@grafana/faro-web-tracing": "^1.9.1",
"@navikt/aksel-icons": "6.16.2",
"@navikt/ds-css": "6.16.2",
"@navikt/ds-react": "6.16.2",
"@navikt/fnrvalidator": "2.1.0",
"@navikt/nav-dekoratoren-moduler": "2.1.6",
"@reduxjs/toolkit": "2.2.6",
"@reduxjs/toolkit": "2.2.7",
"@styled-icons/material": "10.47.0",
"date-fns": "3.6.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-redux": "9.1.2",
"react-router": "6.25.1",
"react-router-dom": "6.25.1",
"react-router": "6.26.1",
"react-router-dom": "6.26.1",
"styled-components": "6.1.12"
}
}
Loading

0 comments on commit d9ffb86

Please sign in to comment.