-
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
1 parent
a928957
commit 90a746e
Showing
29 changed files
with
6,593 additions
and
1 deletion.
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,22 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: gradle | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "03:00" | ||
timezone: Europe/Oslo | ||
open-pull-requests-limit: 10 | ||
|
||
- package-ecosystem: npm | ||
versioning-strategy: increase | ||
directory: "/web-frontend" | ||
schedule: | ||
interval: daily | ||
time: "03:00" | ||
timezone: Europe/Oslo | ||
open-pull-requests-limit: 10 | ||
groups: | ||
npm-dependencies: | ||
patterns: | ||
- "*" |
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,25 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node | ||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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 |
---|---|---|
@@ -1 +1,10 @@ | ||
# spring-react-calculator | ||
# spring-react-calculator | ||
|
||
Starte React/Vite utviklingsmiljø | ||
```bash | ||
cd ./frontend | ||
npm install | ||
npm run dev | ||
``` | ||
Backend må være tilgjengelig på port 8080. | ||
Frontend vil være tilgjengelig på http://localhost/8081. |
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,29 @@ | ||
package no.javatec.calc; | ||
|
||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
public class ApiController { | ||
|
||
// URL for testing localhost: http://localhost:8080/api/5/10/plus | ||
// URL for testing: https://vicx.no/sample/api/5/10/plus | ||
|
||
private final CalculatorService calculatorService; | ||
|
||
public ApiController(CalculatorService calculatorService) { | ||
this.calculatorService = calculatorService; | ||
} | ||
|
||
@RequestMapping( | ||
value = "/api/{firstValue}/{secondValue}/{operation}", | ||
method = RequestMethod.GET, | ||
produces = MediaType.APPLICATION_JSON_VALUE) | ||
public CalcVm index( | ||
@PathVariable long firstValue, | ||
@PathVariable long secondValue, | ||
@PathVariable String operation) { | ||
|
||
return calculatorService.calculate(firstValue, secondValue, operation); | ||
} | ||
} |
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,9 @@ | ||
package no.javatec.calc; | ||
|
||
public record CalcVm( | ||
long firstValue, | ||
long secondValue, | ||
String operation, | ||
Long result | ||
) { | ||
} |
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/no/javatec/calc/CalculatorApplication.java
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,12 @@ | ||
package no.javatec.calc; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class CalculatorApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(CalculatorApplication.class, args); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
backend/src/main/java/no/javatec/calc/CalculatorService.java
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,17 @@ | ||
package no.javatec.calc; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class CalculatorService { | ||
|
||
public CalcVm calculate(long firstValue, long secondValue, String operation) { | ||
Long result = switch (operation) { | ||
case "plus" -> firstValue + secondValue; | ||
case "minus" -> firstValue - secondValue; | ||
default -> null; | ||
}; | ||
|
||
return new CalcVm(firstValue, secondValue, operation, result); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/no/javatec/calc/ServletInitializer.java
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,12 @@ | ||
package no.javatec.calc; | ||
|
||
import org.springframework.boot.builder.SpringApplicationBuilder; | ||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | ||
|
||
public class ServletInitializer extends SpringBootServletInitializer { | ||
|
||
@Override | ||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | ||
return application.sources(CalculatorApplication.class); | ||
} | ||
} |
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 @@ | ||
spring.application.name=spring-react-calculator |
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,2 @@ | ||
group = "no.javatec.calculator" | ||
version = "0.0.1-SNAPSHOT" |
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,10 @@ | ||
plugins { | ||
id("org.siouan.frontend-jdk21") version "8.1.0" | ||
} | ||
|
||
frontend { | ||
nodeVersion.set("20.14.0") | ||
assembleScript.set("run build") | ||
cleanScript.set("run clean") | ||
checkScript.set("run clean") // Change this line when you add tests | ||
} |
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,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + React + TS</title> | ||
</head> | ||
<body class="bg-light"> | ||
<div id="root" class="container"></div> | ||
<script type="module" src="./src/main.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.