-
Notifications
You must be signed in to change notification settings - Fork 5
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
Server til typescript #6038
base: endre-server-auth-til-oasis
Are you sure you want to change the base?
Server til typescript #6038
Conversation
@@ -0,0 +1,37 @@ | |||
import eslint from "@eslint/js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En ganske streng linter jeg ofte tar med meg
@@ -6,7 +6,10 @@ | |||
"type": "module", | |||
"packageManager": "[email protected]", | |||
"scripts": { | |||
"start-express": "node ./server.js" | |||
"build": "ncc build ./src/server.ts -o dist -t --no-cache", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kopiert samme build som brukes i selvbetjening
} | ||
}; | ||
|
||
const skip = () => process.env.NODE_ENV === "production"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hvorfor skipper vi egentlig? Er det kun relevant å logge med morgan lokalt i autotest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Denne logget primært kallene fra isAlive og isReady - dette ble mye spam i prod så jeg skipper denne der.
`${api.path}/*`, | ||
(request, response, next) => { | ||
if (request.timedout) { | ||
logger.warning(`Request for ${request.originalUrl} timed out!`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Her avdekket blandt annet TS en trolig bug ved at det før logges response.originalUrl istedenfor request.originalUrl
server/src/server.ts
Outdated
|
||
// serve static files | ||
server.use(express.static("./")); | ||
server.use("*", (request, response) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forenklet denne til * istedenfor "ikke dist". Da det uans er siste middleware som vil fallbacke til å serve SPAen
server/src/server.ts
Outdated
response.sendFile("index.html"); | ||
}); | ||
|
||
// TODO: her var det en error handler. Jeg tror ikke vi trenger da det fanges av default handler: https://expressjs.com/en/guide/error-handling.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usikker om vi trengte vår egen errorhandler. Som i lenken ser man at express har sin egen som gjorde det samme
Quality Gate passedIssues Measures |
Gjør om server til typescript.
Endringer i byggeprosess:
Workflow må nå inkludere en
yarn build
siden ts må transpileres til js for å kunne kjøre på server. legg til yarn build fp-gha-workflows#202Før kopierte man over hele server mappe (inkl node_modules++). Serverkode kompileres nå til 1 enkelt fil som er det eneste vi kopiere over til /app i image
Image vil nå kun ha en app-folder der det ligger
index.js
som er server koden, og hvor resten av filene er Frontenden