Skip to content

Commit

Permalink
Run format.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
wolverian committed Sep 16, 2024
1 parent a857745 commit 5cde8f5
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 98 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ build/
# VIM
[._]*.un~

# For Prettier specifically
cdk.out/
.next/
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Kielitutkintorekisteri

## Riippuvuudet

- Docker
- PostgreSQL
- maven
- java 21
- node 22.7.0
- npm 10.8.3
- npm 10.8.3

## Kehittäminen

Paikallinen testaus- ja kehitysympäristö vaatii toimiakseen PostgreSQL -tietokannan. Tietokantaa ajetaan Dockerissa ja ne saa käyntiin `docker compose`:lla. Tietokannan skeema alustetaan migraatioilla. Migraatiotyökaluna käytössä on _Flyway_. Migraatioiden suorittamiseen paikallisessa kehitysympäristössä on konfiguroitu Maven-liitännäinen.

```shell
Expand All @@ -26,8 +28,8 @@ Asennettuasi misen voit ajaa komennon `mise install`, ja oikeat java- ja node-ve

### Linttaus

Sovelluksessa käytetään `ktlint` - teknologiaa kotlin - tiedostojen tyylittämiseen. MacOS:llä sen saa asennettua ajamalla `brew install ktlint`. IntelliJ IDEA:aan saa plugin `ktlint`,
jonka asentamisen jälkeen IDEA:n voi laittaa formatoimaan tallentamisen yhteydessä `Settings` -> `Tools` -> `KtLint` alta `Mode`: `Distract free` - radiobutton ja `Format`: `on save` - checkbox täpätty.
Sovelluksessa käytetään `ktlint` - teknologiaa kotlin - tiedostojen tyylittämiseen. MacOS:llä sen saa asennettua ajamalla `brew install ktlint`. IntelliJ IDEA:aan saa plugin `ktlint`,
jonka asentamisen jälkeen IDEA:n voi laittaa formatoimaan tallentamisen yhteydessä `Settings` -> `Tools` -> `KtLint` alta `Mode`: `Distract free` - radiobutton ja `Format`: `on save` - checkbox täpätty.

#### Hyödyllisiä komentoja

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.9'
version: "3.9"

name: kitu

Expand All @@ -12,4 +12,4 @@ services:
POSTGRES_PASSWORD: kitu
PGUSER: kitu
ports:
- '127.0.0.1:5432:5432'
- "127.0.0.1:5432:5432"
26 changes: 13 additions & 13 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, devices } from '@playwright/test';
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
Expand All @@ -11,7 +11,7 @@ import { defineConfig, devices } from '@playwright/test';
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
Expand All @@ -21,31 +21,31 @@ export default defineConfig({
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
trace: "on-first-retry",
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
name: "webkit",
use: { ...devices["Desktop Safari"] },
},

/* Test against mobile viewports. */
Expand All @@ -71,9 +71,9 @@ export default defineConfig({

/* Run your local dev server before starting the tests */
webServer: {
command: './mvnw spring-boot:run',
url: 'http://127.0.0.1:8080',
command: "./mvnw spring-boot:run",
url: "http://127.0.0.1:8080",
reuseExistingServer: !process.env.CI,
cwd: '../server/'
cwd: "../server/",
},
});
10 changes: 5 additions & 5 deletions e2e/tests/hello.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
import { test, expect } from "@playwright/test";

test('unsecured endpoint', async ({ page }) => {
await page.goto('http://127.0.0.1:8080/hello-playwright/index.html');
let content = await page.content()
expect(content).toEqual(expect.stringContaining('hello, playwright'))
test("unsecured endpoint", async ({ page }) => {
await page.goto("http://127.0.0.1:8080/hello-playwright/index.html");
let content = await page.content();
expect(content).toEqual(expect.stringContaining("hello, playwright"));
});
4 changes: 2 additions & 2 deletions frontend/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const nextConfig = {

// The build fails without this.
images: {
unoptimized: true
}
unoptimized: true,
},
};

export default nextConfig;
3 changes: 1 addition & 2 deletions frontend/src/pages/hello-playwright.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export default function HelloPlaywright() {
return <div>hello, playwright</div>
return <div>hello, playwright</div>;
}
5 changes: 1 addition & 4 deletions frontend/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ export default function Home() {
priority
/>
<ol>
<li>
OPH - Kielitutkintorekisteri
</li>
<li>OPH - Kielitutkintorekisteri</li>
</ol>

</main>
<footer className={styles.footer}>
<a
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/styles/Home.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
padding: 0 20px;
border: none;
border: 1px solid transparent;
transition: background 0.2s, color 0.2s, border-color 0.2s;
transition:
background 0.2s,
color 0.2s,
border-color 0.2s;
cursor: pointer;
display: flex;
align-items: center;
Expand Down
21 changes: 4 additions & 17 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"compilerOptions": {
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -17,23 +13,14 @@
"jsx": "preserve",
"incremental": true,
"paths": {
"@/*": [
"./src/*"
]
"@/*": ["./src/*"]
},
"plugins": [
{
"name": "next"
}
]
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
12 changes: 6 additions & 6 deletions infra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ The `cdk.json` file tells the CDK Toolkit how to execute your app.

## Useful commands

* `npm run build` compile typescript to js
* `npm run watch` watch for changes and compile
* `npm run test` perform the jest unit tests
* `npx cdk deploy` deploy this stack to your default AWS account/region
* `npx cdk diff` compare deployed stack with current state
* `npx cdk synth` emits the synthesized CloudFormation template
- `npm run build` compile typescript to js
- `npm run watch` watch for changes and compile
- `npm run test` perform the jest unit tests
- `npx cdk deploy` deploy this stack to your default AWS account/region
- `npx cdk diff` compare deployed stack with current state
- `npx cdk synth` emits the synthesized CloudFormation template
9 changes: 2 additions & 7 deletions infra/cdk.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"app": "npx ts-node --prefer-ts-exts bin/infra.ts",
"watch": {
"include": [
"**"
],
"include": ["**"],
"exclude": [
"README.md",
"cdk*.json",
Expand All @@ -19,10 +17,7 @@
"context": {
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
],
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
Expand Down
10 changes: 5 additions & 5 deletions infra/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
testEnvironment: 'node',
roots: ['<rootDir>/test'],
testMatch: ['**/*.test.ts'],
testEnvironment: "node",
roots: ["<rootDir>/test"],
testMatch: ["**/*.test.ts"],
transform: {
'^.+\\.tsx?$': 'ts-jest'
}
"^.+\\.tsx?$": "ts-jest",
},
};
19 changes: 9 additions & 10 deletions infra/test/infra.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

// example test. To run these tests, uncomment this file along with the
// example resource in lib/infra-stack.ts
test('SQS Queue Created', () => {
// const app = new cdk.App();
// // WHEN
// const stack = new Infra.InfraStack(app, 'MyTestStack');
// // THEN
// const template = Template.fromStack(stack);

// template.hasResourceProperties('AWS::SQS::Queue', {
// VisibilityTimeout: 300
// });
test("SQS Queue Created", () => {
// const app = new cdk.App();
// // WHEN
// const stack = new Infra.InfraStack(app, 'MyTestStack');
// // THEN
// const template = Template.fromStack(stack);
// template.hasResourceProperties('AWS::SQS::Queue', {
// VisibilityTimeout: 300
// });
});
14 changes: 3 additions & 11 deletions infra/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": [
"es2020",
"dom"
],
"lib": ["es2020", "dom"],
"declaration": true,
"strict": true,
"noImplicitAny": true,
Expand All @@ -20,12 +17,7 @@
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": [
"./node_modules/@types"
]
"typeRoots": ["./node_modules/@types"]
},
"exclude": [
"node_modules",
"cdk.out"
]
"exclude": ["node_modules", "cdk.out"]
}
21 changes: 11 additions & 10 deletions server/HELP.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# Getting Started

### Reference Documentation

For further reference, please consider the following sections:

* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/3.3.3/maven-plugin)
* [Create an OCI image](https://docs.spring.io/spring-boot/3.3.3/maven-plugin/build-image.html)
* [Spring Web](https://docs.spring.io/spring-boot/docs/3.3.3/reference/htmlsingle/index.html#web)
* [Spring Boot Actuator](https://docs.spring.io/spring-boot/docs/3.3.3/reference/htmlsingle/index.html#actuator)
- [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
- [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/3.3.3/maven-plugin)
- [Create an OCI image](https://docs.spring.io/spring-boot/3.3.3/maven-plugin/build-image.html)
- [Spring Web](https://docs.spring.io/spring-boot/docs/3.3.3/reference/htmlsingle/index.html#web)
- [Spring Boot Actuator](https://docs.spring.io/spring-boot/docs/3.3.3/reference/htmlsingle/index.html#actuator)

### Guides

The following guides illustrate how to use some features concretely:

* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
* [Building a RESTful Web Service with Spring Boot Actuator](https://spring.io/guides/gs/actuator-service/)
- [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
- [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
- [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
- [Building a RESTful Web Service with Spring Boot Actuator](https://spring.io/guides/gs/actuator-service/)

### Maven Parent overrides

Due to Maven's design, elements are inherited from the parent POM to the project POM.
While most of the inheritance is fine, it also inherits unwanted elements like `<license>` and `<developers>` from the parent.
To prevent this, the project POM contains empty overrides for these elements.
If you manually switch to a different parent and actually want the inheritance, you need to remove those overrides.

0 comments on commit 5cde8f5

Please sign in to comment.