-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
8,886 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Lokaalikehityksessä tarvittavat ympäristömuuttujat. | ||
# Kopioi tämä tiedosto samaan hakemistoon nimelle .env.local ja ylikirjoita arvoja tarvittaessa | ||
VIESTINTAPALVELU_URL=http://localhost:8080/ | ||
LOGIN_URL=http://localhost:8080/login | ||
# matchattava viestintäpalvelun asettaman raportointisession cookien nimeen | ||
COOKIE_NAME=JSESSIONID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
tsconfig.json | ||
package-lock.json | ||
*.typegen.ts | ||
**/playwright/**/*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
trailingComma: "es5" | ||
tabWidth: 2 | ||
semi: true | ||
singleQuote: true | ||
arrowParens: "avoid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## Sovelluksen käynnistäminen paikallisesti | ||
|
||
Lokaali käynnistys tapahtyy komennolla: | ||
|
||
```bash | ||
npm run dev | ||
``` | ||
|
||
ja löytyy osoitteesta [http://localhost:3000](http://localhost:3000) | ||
|
||
Lokaaliympäristössä palvelu toimii lokaalia viestinvälityspalvelua vasten, ks. | ||
https://github.com/Opetushallitus/viestinvalityspalvelu | ||
|
||
TODO lokaalikehitys testiympäristön viestintäpalvelua vasten | ||
|
||
## Yksikkötestien ajo | ||
|
||
Yksikkötestit on tehty vitestillä. Testit saa ajettua komennolla | ||
|
||
```bash | ||
npm test | ||
``` | ||
|
||
## Teknologioista | ||
|
||
Sovellus on toteutettu [Next.js](https://nextjs.org/) -frameworkilla ja luotu [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) -työkalulla. | ||
|
||
Käyttöliittymäkomponenteissa on käytetty [Material UI](https://mui.com/material-ui/getting-started/) -kirjastoa | ||
|
||
## FYI | ||
|
||
Bugin vuoksi juurihakemistossa täytyy olla tyhjä /pages -hakemisto, jotta middleware tulee ajettua lokaalikehitysmoodissa. Ks. https://github.com/vercel/next.js/issues/43141 | ||
|
||
Tämän korjaantumista kannattanee seurailla nextjs-versiopäivityksissä ja poistaa turha hakemisto kun issue on korjattu. | ||
|
||
Jotta lokaaliympäristössä voi käyttää https-apeja self signed sertifikaatilla, täytyy package.jsonin dev-käynnistysasetuksissa olla tämä konfiguraatio: | ||
|
||
```bash | ||
NODE_TLS_REJECT_UNAUTHORIZED=0 | ||
``` | ||
|
||
Ks. https://code-specialist.com/cloud/nextjs-self-signed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { cookieName, loginUrl } from '@/app/lib/configurations' | ||
import { NextResponse } from 'next/server' | ||
import type { NextRequest } from 'next/server' | ||
|
||
export async function middleware(request: NextRequest) { | ||
console.info('middleware') | ||
const cookie = request.cookies.get(cookieName) | ||
if (cookie === undefined) { | ||
console.info('redirect to login') | ||
return NextResponse.redirect(loginUrl); | ||
} | ||
return NextResponse.next(); // Pass control to the next Middleware or route handler | ||
} | ||
|
||
export const config = { | ||
matcher: [ | ||
/* | ||
* Match all request paths except for the ones starting with: | ||
* - api (API routes) | ||
* - _next/static (static files) | ||
* - _next/image (image optimization files) | ||
* - login redirect | ||
* - favicon.ico (favicon file) | ||
*/ | ||
'/((?!api|_next/static|_next/image|login|favicon.ico).*)', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig |
Oops, something went wrong.