Skip to content

Commit

Permalink
Migrerer server til TS og bytter logging
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeofnorway committed Aug 14, 2024
1 parent 937ada5 commit 1f21a88
Show file tree
Hide file tree
Showing 15 changed files with 836 additions and 423 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"plugin:jsx-a11y/recommended",
"prettier"
],
"globals": {
"process": true,
"__dirname": true
},
"settings": {
"react": {
"version": "detect"
Expand All @@ -28,6 +32,7 @@
"semi": ["error", "always"],
"max-len": [1, { "code": 150, "ignoreComments": true, "ignoreStrings": true }],
"indent": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"react/display-name": "off"
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
echo "IMAGE_NAME=$(echo ${GITHUB_REPOSITORY##*/})" >> $GITHUB_ENV
echo "IMAGE_VERSION=${IMAGE_VERSION_RAW,,}" >> $GITHUB_ENV
echo "GITHUB_TOKEN=$(echo ${GITHUB_TOKEN})" >> $GITHUB_ENV
echo "PUBLIC_URL=https://cdn.nav.no/personbruker/personopplysninger/$(echo ${IMAGE_VERSION_RAW,,})/build" >> $GITHUB_ENV
echo "PUBLIC_URL=https://cdn.nav.no/personbruker/personopplysninger/$(echo ${IMAGE_VERSION_RAW,,})/build/client" >> $GITHUB_ENV
- name: Define client-side environment
run: |
echo "VITE_ENV=${{ inputs.env }}" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# production
/build

/server-build

# misc
.DS_Store
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ FROM node:20-bullseye-slim
ENV NODE_ENV production

WORKDIR usr/src/app
COPY server server/
COPY build build/
COPY server/node_modules build/server/node_modules

WORKDIR server

CMD ["node", "./server.js"]
CMD ["node", "./build/server/server.js"]

EXPOSE 8080
161 changes: 160 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx",
"postinstall": "cd server && npm install",
"build": "npm-run-all -p build:*",
"build:server": "cd server && npm run build",
"build:js": "vite build",
"build:css": "less-watch-compiler --run-once",
"test": "vitest",
Expand Down
22 changes: 0 additions & 22 deletions server/dekorator.js

This file was deleted.

22 changes: 22 additions & 0 deletions server/dekorator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { injectDecoratorServerSide } from '@navikt/nav-dekoratoren-moduler/ssr';

type DecoratorNaisEnv = 'prod' | 'dev' | 'beta' | 'betaTms' | 'devNext' | 'prodNext';

export const getHtmlWithDecorator = (filePath: string) =>
injectDecoratorServerSide({
env: process.env.ENV as DecoratorNaisEnv,
filePath,
params: {
enforceLogin: false,
breadcrumbs: [
{ url: 'https://www.nav.no/minside/', title: 'Min side' },
{ url: 'https://www.nav.no/person/personopplysninger/', title: 'Personopplysninger' },
],
availableLanguages: [
{ url: 'https://www.nav.no/person/personopplysninger/nb/', locale: 'nb' },
{ url: 'https://www.nav.no/person/personopplysninger/en/', locale: 'en' },
{ url: 'https://www.nav.no/person/personopplysninger/nn/', locale: 'nn' },
],
logoutWarning: true,
},
});
12 changes: 0 additions & 12 deletions server/logger.js

This file was deleted.

11 changes: 11 additions & 0 deletions server/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { LoggerOptions, pino } from 'pino';

const options = {
formatters: {
level: (label) => {
return { level: label };
},
},
} as LoggerOptions;

export const logger = pino(options);
Loading

0 comments on commit 1f21a88

Please sign in to comment.